Connor Crofton

Connor Crofton

  • NA
  • 1
  • 1.4k

The Cactus Cantina

Oct 16 2016 12:20 PM
create a C# program for The Cactus Cantina named FoodOrder that accepts a user's choice from the options in the accompanying table. Allow the user to enter either an integer item number or a string description. Pass the user's entry to one of two overloaded GetDetails() methods and then display the returned string.
 
The method version that accepts an integer looks up the description and price and returns a string with all the order details.
 
The version that accepts a string description looks up the item number and price and returns a string with all the order details. The methods return an appropriate message if the item is not found.
 
Here's the table info:
  • ItemNumber: 20, 23, 25, 31
  • Description: Enchilada, Burrito, Taco, Tostada
  • Price: 2.95, 1.95, 2.25, 3.10
I already have the items added, but I'm having difficulty trying to create the GetDetails() methods. Please help me with this issue. Thanks!
 
Here's the code I have so far:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CCroftonFoodOrder
{
class Program
{
static void Main()
{
Console.WriteLine("ItemNum | Description | Price");
Inventory inventory = new Inventory();
inventory.Add(new Item() { ItemNum = 20, Description = "Enchilada", Price = 2.95 });
Order order = new Order();
Console.WriteLine("Enter a food number or description");
}
}
public class Item
{
public string Description;
public double Price;
public int ItemNum;
public override string ToString()
{
return string.Format("{0} | {1} | {2}", ItemNum, Description, Price);
}
}
public class Inventory
{
// manages all items of this inventory
List<Item> items = new List<Item>();
// Adds an Item to the managed items
public void Add(Item item)
{
items.Add(new Item() { ItemNum = 20, Description = "Enchilada", Price = 2.95 });
items.Add(new Item() { ItemNum = 23, Description = "Burrito", Price = 1.95 });
items.Add(new Item() { ItemNum = 25, Description = "Taco", Price = 2.25 });
items.Add(new Item() { ItemNum = 31, Description = "Tostada", Price = 3.10 });
Console.WriteLine();
foreach (Item aItem in items)
{
Console.WriteLine(aItem);
}
}
}
public class Order
{
}
}