Create a class named Pizza. Data fields include a string for toppings (such as pepperoni), an integer for diameter in inches (such as 12), and a double for price (such as 13.99). Include properties to get and set values for each of these fields. Create a class named TestPizza that instantiates one Pizza object and demonstrates the use of the Pizza set and get accessors
class Pizza
{
string toppings;
int diameter;
double price;
}
public string Toppings
{
get
{
return this.toppings;
}
set
{
this.toppings = value;
}
}
public int Diameter
{
get
{
return this.diameter;
}
set
{
this.diameter = value;
}
}
public double Price
{
get
{
return this.price;
}
set
{
this.price = value;
}
}
public class TestPizza
{
public static void main(String[] args)
{
Pizza p = new Pizza();
p.Toppings = "pepperoni, cheese, mushrooms";
p.Diameter = 12;
p.Price = 13.99;
Console.WriteLine("Topping: " + p.getTopping());
Console.WriteLine("Diameter: " + p.getDiameter());
Console.WriteLine("Price: " + p.getPrice());
}
}
Expected class, delegate, enum, interface, or struct is the error that i am getting with: public string toppings,public int Diameter and public double Price.