Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person {
- private String name;
- public Person(String name) {
- this.name = name;
- }
- public String getName() { return name; }
- public void sing(String song, Person singTo) throws InterruptedException {
- if (song.equals("Happy Birthday")) {
- for (int i = 0; i < 2; i++) {
- System.out.println("Happy Birthday to you,");
- Thread.sleep(2000);
- }
- System.out.println("Happy Birthday, dear " + singTo.getName() + ",");
- Thread.sleep(2500);
- System.out.println("Happy Birthday to you!");
- Thread.sleep(2000);
- System.out.println("\n~From " + name + " <3");
- }
- }
- }
- public class HappyBirthday {
- public static void main(String[] args) throws InterruptedException {
- Person me = new Person("Calvin");
- me.sing("Happy Birthday", new Person("Giulio"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement