Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Pizza{
- string size;
- int che , pep , ham;
- public Pizza(string s , int a , int b , int c){
- size = s;
- che = a;
- pep = b;
- ham = c;
- }
- public string Size{
- get {return size;}
- set {size = value;}
- }
- public int Che{
- get {return che;}
- set {che = value;}
- }
- public int Pep{
- get {return pep;}
- set {pep = value;}
- }
- public int Ham{
- get {return ham;}
- set {ham = value;}
- }
- public double CalcCost(){
- double cost = 0.0;
- if(size == "small")
- cost += 10.0;
- if(size == "medium")
- cost += 12.0;
- if(size == "large")
- cost += 14.0;
- cost += ((che + pep + ham) * 2.0);
- return (cost * 1.0);
- }
- public string getDescription(){
- string s = "";
- s += size;
- s += "\nCheese toppings - ";
- s += che;
- s += "\nPepperoni toppings - ";
- s += pep;
- s += "\nHam toppings - ";
- s += ham;
- return s;
- }
- }
- class Program{
- public static void Main(){
- Console.WriteLine("How many Pizzas do you want?");
- int t = int.Parse(Console.ReadLine());
- double all = 0.0;
- while(t > 0){
- t--;
- Console.WriteLine("Size (small, medium, large):");
- string s = Console.ReadLine();
- Console.WriteLine("Cheese toppings:");
- int a = int.Parse(Console.ReadLine());
- Console.WriteLine("Pepperoni toppings:");
- int b = int.Parse(Console.ReadLine());
- Console.WriteLine("Ham toppings:");
- int c = int.Parse(Console.ReadLine());
- Pizza exp = new Pizza(s , a , b , c);
- double sum = exp.CalcCost();
- Console.WriteLine($"Price: $ {sum * 1.00}");
- all += (sum * 1.00);
- }
- Console.WriteLine($"Total Price: $ {all * 1.00}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement