Advertisement
LEGEND2004

just

Dec 3rd, 2022
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. using System;
  2.  
  3. class Pizza{
  4. string size;
  5. int che , pep , ham;
  6.  
  7. public Pizza(string s , int a , int b , int c){
  8. size = s;
  9. che = a;
  10. pep = b;
  11. ham = c;
  12. }
  13.  
  14. public string Size{
  15. get {return size;}
  16. set {size = value;}
  17. }
  18. public int Che{
  19. get {return che;}
  20. set {che = value;}
  21. }
  22. public int Pep{
  23. get {return pep;}
  24. set {pep = value;}
  25. }
  26. public int Ham{
  27. get {return ham;}
  28. set {ham = value;}
  29. }
  30. public double CalcCost(){
  31. double cost = 0.0;
  32. if(size == "small")
  33. cost += 10.0;
  34. if(size == "medium")
  35. cost += 12.0;
  36. if(size == "large")
  37. cost += 14.0;
  38. cost += ((che + pep + ham) * 2.0);
  39. return (cost * 1.0);
  40. }
  41. public string getDescription(){
  42. string s = "";
  43. s += size;
  44. s += "\nCheese toppings - ";
  45. s += che;
  46. s += "\nPepperoni toppings - ";
  47. s += pep;
  48. s += "\nHam toppings - ";
  49. s += ham;
  50. return s;
  51. }
  52. }
  53.  
  54. class Program{
  55. public static void Main(){
  56. Console.WriteLine("How many Pizzas do you want?");
  57. int t = int.Parse(Console.ReadLine());
  58. double all = 0.0;
  59. while(t > 0){
  60. t--;
  61. Console.WriteLine("Size (small, medium, large):");
  62. string s = Console.ReadLine();
  63. Console.WriteLine("Cheese toppings:");
  64. int a = int.Parse(Console.ReadLine());
  65. Console.WriteLine("Pepperoni toppings:");
  66. int b = int.Parse(Console.ReadLine());
  67. Console.WriteLine("Ham toppings:");
  68. int c = int.Parse(Console.ReadLine());
  69. Pizza exp = new Pizza(s , a , b , c);
  70. double sum = exp.CalcCost();
  71. Console.WriteLine($"Price: $ {sum}.00");
  72. all += sum;
  73. }
  74. Console.WriteLine($"Total Price: $ {all}.00");
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement