Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please just c# no javascript or ny other language Design a class named Pizza. Da

ID: 3834064 • Letter: P

Question

please just c# no javascript or ny other language

Design a class named Pizza. Data fields include a string field for a topping
(such as pepperoni) and numeric fields for diameter in inches (such as 12)
and price (such as 13.99). Include methods to get and set values for each of
these fields. Create the class diagram and write the pseudocode that defines
the class.
b. Design an application that declares two Pizza objects and sets and displays
their values.
c. Design an application that declares an array of 10 Pizza objects. Prompt the
user for data for each Pizza, then display all the values.
d. Design an application that declares an array of 10 Pizza objects. Prompt the
user for a topping and diameter for each Pizza, and pass each object to a
method that computes the price and returns the complete Pizza object to the
main program. Then display all the Pizza values. A 12inch pizza is $13.99, a
14inch pizza is $16.99, and a 15inch pizza is $19.99. Any other entered size is
invalid and should cause the price to be set to 0.

Explanation / Answer

class digram

Pizza

----------------------

topping:string

price:double

diameter:double

-------------------

getTopping():string

getPrice():double

getDiameter():double

setTopping():void

setPrice():void

setDiameter():void

-----------------------------------------

//note i ahve put all the b c d in same program.

//you can seprate it according to your convenience or make main method small by putting redunadant code in //smaller methods.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PizaaSharp
{
class Pizza
{
string topping;
double price;
double diameter;
  
public void setTopping(String topping)
{
this.topping = topping;
}

public void setPrice(double price)
{
this.price = price;
}
public void setDiameter(double diameter)
{
this.diameter = diameter;
}

public string getTopping()
{
return topping;
}

public double getPrice()
{
return price;
}

public double getDiamter()
{
return diameter;
}

}


class Program
{
static void Main(string[] args)
{

Pizza a = new Pizza();
a.setTopping("pamesan");
a.setDiameter(12);
a.setPrice(13.99);

Pizza b = new Pizza();
b.setTopping("mozarella");
b.setDiameter(15);
b.setPrice(19.99);


Console.WriteLine("topping: {0} dimater: {1} price: {2}", a.getTopping(), a.getDiamter(), a.getPrice());
Console.WriteLine("topping: {0} dimater: {1} price: {2}", b.getTopping(), b.getDiamter(), b.getPrice());

Pizza[] pizzas = new Pizza[10];

for(int i=0;i<pizzas.Length;i++)
{
Console.WriteLine("enter topping: ");
string topping = Console.ReadLine();
Console.WriteLine("enter price: ");
double price = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("enter diamter: ");
double diameter = Convert.ToDouble(Console.ReadLine());

Pizza p = new Pizza();
p.setTopping(topping);
p.setDiameter(diameter);
p.setPrice(price);

pizzas[i] = p;

}

for (int i = 0; i < pizzas.Length; i++)
{

Console.WriteLine("topping: {0} dimater: {1} price: {2}", pizzas[i].getTopping(), pizzas[i].getDiamter(), pizzas[i].getPrice());

}


for (int i = 0; i < pizzas.Length; i++)
{
Console.WriteLine("enter topping: ");
string topping = Console.ReadLine();
Console.WriteLine("enter price: ");
double price = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("enter diamter: ");
double diameter = Convert.ToDouble(Console.ReadLine());

Pizza p = new Pizza();
p.setTopping(topping);
p.setDiameter(diameter);

pizzas[i] = computePrice(p);


}

for (int i = 0; i < pizzas.Length; i++)
{

Console.WriteLine("topping: {0} dimater: {1} price: {2}", pizzas[i].getTopping(), pizzas[i].getDiamter(), pizzas[i].getPrice());

}
}


public static Pizza computePrice(Pizza p)
{
if(p.getDiamter()==12)
{
p.setPrice(13.99);
}
else if(p.getDiamter()==14)
{
p.setPrice(16.99);
}
else if(p.getDiamter()==15)
{
p.setPrice(19.99);
}
else
{
p.setPrice(0);
}

return p;
  
}

}
}