Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace IntroductionToCSharpSession3
- {
- /// <summary>
- /// Types of item that can be found in the menu
- /// </summary>
- public enum MenuType
- {
- Food,
- HotDrink,
- ColdDrink,
- Sweet,
- Snack
- }
- /// <summary>
- /// Represents an item in the menu
- /// </summary>
- public class MenuItem
- {
- public string ItemName { get; set;}
- public decimal Prices { get; set; }
- public decimal Calories { get; set; }
- public MenuType ItemType { get; set; }
- public MenuItem(string itemName, decimal price, decimal calories, MenuType itemType)
- {
- ItemName = itemName;
- Prices = price;
- Calories = calories;
- ItemType = itemType;
- }
- }
- /// <summary>
- /// Represents a menu
- /// </summary>
- public class Menu
- {
- public List<MenuItem> MainMenu = new List<MenuItem>();
- /// <summary>
- /// Default constructor, let's construct the menu here.
- /// </summary>
- public Menu()
- {
- //create several MenuItem and then add it to the list;
- MenuItem item1 = new MenuItem("Laksa", 5.50m, 587, MenuType.Food);
- MainMenu.Add(item1);
- }
- /// <summary>
- /// Displays the menu
- /// </summary>
- public void DisplayTheMenu()
- {
- foreach(MenuItem item in MainMenu)
- {
- Console.WriteLine(item.ItemName);
- }
- }
- }
- /// <summary>
- /// This is the main program class
- /// </summary>
- class MainClass
- {
- public static void Main(string[] args)
- {
- Console.WriteLine("Welcome to Bersama-Sama Restaurant!");
- //create an instance of the menu
- Menu myRestaurantMenu = new Menu();
- //this represent the orders that have been done by the customer
- Dictionary<MenuItem, int> Orders = new Dictionary<MenuItem, int>();
- //Step 1 - displays the menu
- //Step 2 - ask the user what they want to order, until they
- // type "done"
- //need to check if what ordered by the customer is found in "myRestaurant" menu.
- //if it is found, then add it to "Orders"
- //if not found, show error message.
- //Step 3 - when the order is finished, calculates the total
- //for the bill, apply 6% GST, apply 10% service charge
- //and then inform the customer the amount of calories in their food
- }
- /// <summary>
- /// Calculates the total calories given the orders
- /// </summary>
- /// <returns>The total calories.</returns>
- /// <param name="orders">Orders.</param>
- public static decimal CalculateTotalCalories(Dictionary<MenuItem, int> orders)
- {
- decimal totalCalories = 0;
- foreach(MenuItem item in orders.Keys)
- {
- int quantity = orders[item];
- decimal calories = item.Calories;
- decimal itemCalories = quantity * calories;
- totalCalories += itemCalories;
- }
- return totalCalories;
- }
- /// <summary>
- /// Calculate the total of the receipt
- /// </summary>
- /// <returns>The total.</returns>
- /// <param name="orders">Orders.</param>
- public static decimal CalculateTotal(Dictionary<MenuItem, int> orders)
- {
- //todo: write a loop that will calculate the total amount of the order.
- return 0;
- }
- /// <summary>
- /// Calculates the GST
- /// </summary>
- /// <returns>The gst.</returns>
- /// <param name="total">Total.</param>
- public static decimal CalculateGST(decimal total)
- {
- //todo: calculate the 6% GST
- return 0;
- }
- }
- }
Add Comment
Please, Sign In to add comment