TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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. T
he 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
{
}
}
Reply
Answers (
0
)
collect variables
How to do textchanged event with html combobox box in asp.ne