Advertisement
IrinaIgnatova

Exam-JavaAdvanced-17.12-MainClass

Dec 26th, 2019
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. package christmas;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Bag bag = new Bag("black", 10);
  6.  
  7. // Initialize entity
  8.         Present present = new Present("Doll", 0.4, "girl");
  9.  
  10. // Print Present
  11.         System.out.println(present); // Present Doll (0.40) for a girl
  12.  
  13. // Add Present
  14.         bag.add(present);
  15.  
  16. // Remove Present
  17.         bag.remove("Toy"); // false
  18.  
  19.         Present secondPresent = new Present("Train", 2, "boy");
  20. // Add Present
  21.         bag.add(secondPresent);
  22.  
  23.         Present heaviestPresent = bag.heaviestPresent();
  24.         System.out.println(heaviestPresent);
  25. // Present Train (2.00) for a boy
  26.  
  27.        // Present p = bag.getPresent("Doll");
  28.        // System.out.println(p);
  29. // Present Doll (0.40) for a girl
  30.  
  31.         System.out.println(bag.count()); // 2
  32.        // System.out.println(bag.report());
  33.  
  34. // Black bag contains:
  35. // Present Doll (0.40) for a girl
  36. // Present Train (2.00) for a boy
  37.  
  38.  
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement