Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. public class LAB13 {
  2.  
  3. /**
  4. * @param args the command line arguments
  5. */
  6. public static void main(String[] args) {
  7.  
  8. Pizza p1 = new Pizza();
  9. p1.type = 'P';
  10. p1.size = 'L';
  11. p1.toppings = 5;
  12. p1.price=0;
  13. double price1 = p1.calculatePrice();
  14. System.out.println("the price of p1: "+price1+" kd ");
  15.  
  16. Pizza p2 = new Pizza();
  17. p2.type = 'T';
  18. p2.size = 'M';
  19. p2.toppings = 7;
  20. p2.price=0;
  21.  
  22. double price2 = p2.calculatePrice();
  23. System.out.println("the price of p2: "+price2+" kd");
  24.  
  25. System.out.println(p1.toString());
  26. System.out.println(p2.toString());
  27.  
  28.  
  29.  
  30. if(p1.hasResonablePrice()){
  31. System.out.println("price of p1 is reasonable");
  32. }
  33. else{
  34. System.out.println("price of p1 is not reasonable");
  35. }
  36.  
  37.  
  38. if(p2.isMoreExpensiveThan(3)){
  39. System.out.println("price of p2 is more than 3 kd");
  40. }
  41. else{
  42. System.out.println("the price of p2 is less than 3 kd");
  43. }
  44.  
  45.  
  46. if(p1.isMoreExpensiveThan(p2.price)){
  47. System.out.println("p1 pizza is more expensive than p2");
  48. }
  49. else{
  50. System.out.println("p2 pizza is more expensive than p1");
  51. }
  52.  
  53.  
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement