I am creating something like a kiosk program where you order food from using windows forms. I have to create a Toppings Class where it contains three fields that are arrays.
- ToppingList as an array of bool
- ToppingNames as an array of string
- ToppingPrices as an array of double
The instructions say that the constructor must accept a single argument: the length of all three arrays which are parallel arrays.
I am not sure how to do this. I have researched and understand how parallel arrays work but I do not know how to implement and get all three lengths in a single argument. I am not sure if I am doing this correctly?
This is what I have so far:
namespace DeliAndPizza
{
class Toppings
{
bool[] ToppingList = { false, false, false, false, false, false, false, false, false, false, false, false };
string[] ToppingNames = { "Bacon", "Extra Cheese", "Hot Peppers", "Mayo", "Mushrooms", "Oil", "Onion", "Onion", "Oregano", "Peppers", "Sausage" };
double[] ToppingPrices = {1.00, 1.50, 0.00, 0.00, 1.00, 0.00, 0.00, 1.00, 0.00, 1.00, 1.00, 0.00 };
public Toppings()
{
}
public Toppings(bool[] list, string[] name, double[] price)
{
this.ToppingList = list;
this.ToppingNames = name;
this.ToppingPrices = price;
}
}
}
Here is the given class diagram: