So i need to create a class called "store" in this class i need to have a method called "start", now in said method i need to create 9 objects from different classes. I then need to call on said method in the main program and be able to refer to said created objects after having called the message.
class Store
{
public void start()
{
Pizza vesuvio = new Pizza("Vesuvio", 75, "Tomato", "Cheese", "Ham");
Pizza vegetarian = new Pizza("Vegetarian", 80, "Tomato", "cheese", "vegetables");
Pizza contadina = new Pizza("Containda", 75, "Tomato", "cheese", "mushrooms", "olives");
Customer victor = new Customer("Victor", "Hansen");
Customer jacob = new Customer("Jacob", "Pedersen");
Customer maghrete = new Customer("Maghrete", "Ingrid");
Order victorOrdre = new Order(vesuvio.PizzaPrice, 1.25, vesuvio.PizzaPrice * 1.25);
Order jacobOrdre = new Order(vegetarian.PizzaPrice, 1.25, vegetarian.PizzaPrice * 1.25);
Order maghreteOrdre = new Order(contadina.PizzaPrice, 1.25, contadina.PizzaPrice * 1.25);
return;
}
}
This is the method i have created but i can't seem to be able to call the method in the main program no matter what i return or what i change the type to. This is what i've been instructed to do
- To test your application you should create a class Store with a method Start.
- Call the Start method from the main method in the class Program.
- In the Start method you should:
- Create 3 Pizza objects, 3 Customer objects and 3 Order objects each with a different pizza.
- Print out order information
- Using the object reference to each Order object, you should print out the pizza name, the customer name and the total price for each order.
public class Order
{
// instance fields
private double _tax;
private int _priceBeforeTaxes;
private double _totalPrice;
//properties
public double Tax
{
get { return _tax; }
set { _tax = 0.25; }
}
public int PriceBeforeTaxes
{
get { return _priceBeforeTaxes; }
}
public double TotalPrice
{
get { return _totalPrice; }
}
//constructor
public Order(int priceBeforeTax, double tax, double totalPrice)
{
_priceBeforeTaxes = priceBeforeTax;
_tax = tax;
_totalPrice = totalPrice;
}
//methods
public override string ToString()
{
string obj = $"order total before taxes is {PriceBeforeTaxes} with taxes of 25% is equal to {TotalPrice} ";
return obj;
}
public double CalculateTotalPrice(int PriceBeforeTaxes, double Tax)
{
double CalculatedTotalPrice = PriceBeforeTaxes * Tax;
return CalculatedTotalPrice;
}
}
public class Pizza
{
private string _pizzaName;
public int _pizzaPrice;
private string _pizzaToppings1;
private string _pizzaToppings2;
private string _pizzaToppings3;
private string _pizzaToppings4;
//Properties
public string PizzaName
{
get { return _pizzaName; }
}
public int PizzaPrice
{
get { return _pizzaPrice; }
}
public string PizzaToppings1
{
get { return _pizzaToppings1; }
}
public string PizzaToppings2
{
get { return _pizzaToppings2; }
}
public string PizzaToppings3
{
get { return _pizzaToppings3; }
}
public string PizzaToppings4
{
get { return _pizzaToppings4; }
}
//constructor
public Pizza(string pizzaName, int pizzaPrice, string pizzaToppings1, string pizzaToppings2, string pizzaToppings3)
{
_pizzaName = pizzaName;
_pizzaPrice = pizzaPrice;
_pizzaToppings1 = pizzaToppings1;
_pizzaToppings2 = pizzaToppings2;
_pizzaToppings3 = pizzaToppings3;
}
public Pizza(string pizzaName, int pizzaPrice, string pizzaToppings1, string pizzaToppings2, string pizzaToppings3, string pizzaToppings4)
{
_pizzaName = pizzaName;
_pizzaPrice = pizzaPrice;
_pizzaToppings1 = pizzaToppings1;
_pizzaToppings2 = pizzaToppings2;
_pizzaToppings3 = pizzaToppings3;
_pizzaToppings4 = pizzaToppings4;
}
//method
public override string ToString()
{
string obj = $"{PizzaName} with {PizzaToppings1}, {PizzaToppings2}, {PizzaToppings3}, {PizzaToppings4} costs {PizzaPrice}kr";
return obj;
}
}
public class Customer
{
private string _customerFirstName;
private int _customerNumber;
private string _customerAddress;
private string _customerLastName;
//properties
public string CustomerFirstName
{
get { return _customerFirstName; }
set { _customerFirstName = value; }
}
public string CustomerLastName
{
get { return _customerLastName; }
set { _customerLastName = value; }
}
public int CustomerNumber
{
get { return _customerNumber; }
set { _customerNumber = value; }
}
public string CustomerAddress
{
get { return _customerAddress; }
set { _customerAddress = value; }
}
//constructor
public Customer(string CustomerFirstName, string CustomerLastName, int CustomerNumber, string CustomerAddress)
{
_customerFirstName = CustomerFirstName;
_customerNumber = CustomerNumber;
_customerAddress = CustomerAddress;
_customerLastName = CustomerLastName;
if (CustomerNumber < 100000000 && CustomerNumber > 9999999)
{
}
else
{
Console.WriteLine("this is not a valid phone number, valid phone number must be 8 digits. Please try again.");
}
}
//methods
public override string ToString()
{
string obj = $"{CustomerFirstName}, {CustomerLastName}, \n{CustomerNumber}, \n{CustomerAddress}";
return obj;
}
}
class Program
{
static void Main(string[] args)
{
Store store = new Store();
store.start();
}
}
That is where I'm supposed to call the method and refer to the objects I created in the method.