Reputation: 1
I'm stuck on this program where I have to create Implement a class Pizza which I did
The part where I got stuck sounds like this
Create a class MenuCatalog, that contains pizzas, and implement methods for CRUD operations (Create, Read, Update and Delete).
Implement a method, PrintMenu, that can print out the menu card (to the screen).
Implement a method SearchPizza(criteria), that searches for a pizza and returns a Pizza object.
In the class Store implement code to test the implemented classes and methods in step 2.
Create a user dialog for the system. Create a method menu choice that prints out a list of menu items and reads the users choice
So far my program looks like this on the pizza class :
using System;
namespace PizzaStore
{
public class Pizza
{
private int _pizzaID;
private double _price;
private string _size;
private Topping _toppings;
public Pizza (int pizzaID, double price, string size, Topping toppings)
{
_pizzaID = pizzaID;
_price = price;
_size = size;
_toppings = toppings;
}
public int pizzaID
{
get { return _pizzaID; }
set { _pizzaID = value; }
}
public double price
{
get { return _price; }
set { _price = value; }
}
public string size
{
get { return _size; }
set { _size = value; }
}
public Topping toppings
{
get { return _toppings; }
set { _toppings = value; }
}
public override string ToString()
{
return $"The pizza ID is {_pizzaID}, the size is {_size}, with {_toppings.Name}. The price is {_price}.";
}
//
}
The part where I got really stuck is at the Menu catalog thing :( I'm stuck even at basic stuff such as inserting items, because wherever I search something I'll find different forms that will not work with this.
I tried something like this :
public class MenuCatalog
int index = 0
List<MenuCatalog> Pizza = new List<MenuCatalog>
and then trying to create items based on that.Or I tried with different forms for the inseration such as Pizza p1 = new Pizza( ) ;
Any ideeas on how I should proceed, please? :(
Upvotes: 0
Views: 480
Reputation: 5804
Ok, let's have a look what we need:
Pizza
ClassThat's done, but you could simplify a little bit to something like this (you need all existing properties, I removed most of them only to keep the demo short).
public class Pizza
{
public Pizza (int id, double price, string size, Topping toppings)
{
ID = ID;
Price = price;
...
}
public int ID { get; set; }
public double Price { get; set; }
}
Changes:
We want to store a "all available" pizzas, so that will be a list that contains pizzas.
public class MenuCatalog
{
private List<Pizza> _allPizzas = new List<Pizza>();
public void Add(Pizza pizza) {
_allPizzas.Add(pizza);
}
}
Here you can add all methods to manipulate and search the data.
As soon as you have the data part, you can add features that allow users to show and do something with pizzas. How this works depends on the type of your application (HTML, Desktop app, mobile, ...)
Good luck ;-)
Upvotes: 1