Guest User

Untitled

a guest
Jan 20th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace IntroductionToCSharpSession3
  5. {
  6. /// <summary>
  7. /// Types of item that can be found in the menu
  8. /// </summary>
  9. public enum MenuType
  10. {
  11. Food,
  12. HotDrink,
  13. ColdDrink,
  14. Sweet,
  15. Snack
  16. }
  17.  
  18. /// <summary>
  19. /// Represents an item in the menu
  20. /// </summary>
  21. public class MenuItem
  22. {
  23. public string ItemName { get; set;}
  24. public decimal Prices { get; set; }
  25. public decimal Calories { get; set; }
  26. public MenuType ItemType { get; set; }
  27.  
  28. public MenuItem(string itemName, decimal price, decimal calories, MenuType itemType)
  29. {
  30. ItemName = itemName;
  31. Prices = price;
  32. Calories = calories;
  33. ItemType = itemType;
  34. }
  35. }
  36.  
  37. /// <summary>
  38. /// Represents a menu
  39. /// </summary>
  40. public class Menu
  41. {
  42. public List<MenuItem> MainMenu = new List<MenuItem>();
  43.  
  44. /// <summary>
  45. /// Default constructor, let's construct the menu here.
  46. /// </summary>
  47. public Menu()
  48. {
  49. //create several MenuItem and then add it to the list;
  50. MenuItem item1 = new MenuItem("Laksa", 5.50m, 587, MenuType.Food);
  51. MainMenu.Add(item1);
  52.  
  53. }
  54.  
  55. /// <summary>
  56. /// Displays the menu
  57. /// </summary>
  58. public void DisplayTheMenu()
  59. {
  60. foreach(MenuItem item in MainMenu)
  61. {
  62. Console.WriteLine(item.ItemName);
  63. }
  64. }
  65. }
  66.  
  67. /// <summary>
  68. /// This is the main program class
  69. /// </summary>
  70. class MainClass
  71. {
  72. public static void Main(string[] args)
  73. {
  74. Console.WriteLine("Welcome to Bersama-Sama Restaurant!");
  75.  
  76. //create an instance of the menu
  77. Menu myRestaurantMenu = new Menu();
  78.  
  79. //this represent the orders that have been done by the customer
  80. Dictionary<MenuItem, int> Orders = new Dictionary<MenuItem, int>();
  81.  
  82. //Step 1 - displays the menu
  83.  
  84. //Step 2 - ask the user what they want to order, until they
  85. // type "done"
  86.  
  87. //need to check if what ordered by the customer is found in "myRestaurant" menu.
  88. //if it is found, then add it to "Orders"
  89. //if not found, show error message.
  90.  
  91.  
  92. //Step 3 - when the order is finished, calculates the total
  93. //for the bill, apply 6% GST, apply 10% service charge
  94. //and then inform the customer the amount of calories in their food
  95.  
  96. }
  97.  
  98. /// <summary>
  99. /// Calculates the total calories given the orders
  100. /// </summary>
  101. /// <returns>The total calories.</returns>
  102. /// <param name="orders">Orders.</param>
  103. public static decimal CalculateTotalCalories(Dictionary<MenuItem, int> orders)
  104. {
  105. decimal totalCalories = 0;
  106.  
  107. foreach(MenuItem item in orders.Keys)
  108. {
  109. int quantity = orders[item];
  110. decimal calories = item.Calories;
  111. decimal itemCalories = quantity * calories;
  112. totalCalories += itemCalories;
  113. }
  114.  
  115. return totalCalories;
  116. }
  117.  
  118. /// <summary>
  119. /// Calculate the total of the receipt
  120. /// </summary>
  121. /// <returns>The total.</returns>
  122. /// <param name="orders">Orders.</param>
  123. public static decimal CalculateTotal(Dictionary<MenuItem, int> orders)
  124. {
  125. //todo: write a loop that will calculate the total amount of the order.
  126. return 0;
  127. }
  128.  
  129. /// <summary>
  130. /// Calculates the GST
  131. /// </summary>
  132. /// <returns>The gst.</returns>
  133. /// <param name="total">Total.</param>
  134. public static decimal CalculateGST(decimal total)
  135. {
  136. //todo: calculate the 6% GST
  137. return 0;
  138. }
  139. }
  140. }
Add Comment
Please, Sign In to add comment