Advertisement
UrNotSorry

Happy Birthday, Giulio!

Jan 31st, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. class Person {
  2.    
  3.     private String name;
  4.    
  5.     public Person(String name) {
  6.         this.name = name;
  7.     }
  8.    
  9.     public String getName() { return name; }
  10.    
  11.     public void sing(String song, Person singTo) throws InterruptedException {
  12.        
  13.         if (song.equals("Happy Birthday")) {
  14.            
  15.             for (int i = 0; i < 2; i++) {
  16.                 System.out.println("Happy Birthday to you,");
  17.                 Thread.sleep(2000);
  18.             }
  19.            
  20.             System.out.println("Happy Birthday, dear " + singTo.getName() + ",");
  21.             Thread.sleep(2500);
  22.            
  23.             System.out.println("Happy Birthday to you!");
  24.             Thread.sleep(2000);
  25.            
  26.             System.out.println("\n~From " + name + " <3");
  27.         }
  28.     }
  29. }
  30.  
  31. public class HappyBirthday {
  32.  
  33.     public static void main(String[] args) throws InterruptedException {
  34.         Person me = new Person("Calvin");
  35.         me.sing("Happy Birthday", new Person("Giulio"));
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement