Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
130 lines (110 loc) · 4.28 KB
/
Copy pathProgram.cs
File metadata and controls
130 lines (110 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace RecipeApp
{
class Program
{
//object of Recipe
public static Recipe Recipe = new Recipe();
#region Main
static void Main(string[] args)
{
//Main Menu
mainMenu();
//keep console open
Console.ReadLine();
}
#endregion
#region MainMenu
public static void mainMenu()
{
Console.WriteLine("******************************");
Console.WriteLine("Welcome to Recipe Application");
Console.WriteLine("******************************");
while (true)
{
Console.WriteLine("\nWelcome to the Main Menu of RecipeApp.\nEnter a number to continue:");
Console.WriteLine("1. Add Recipe?" +
"\n2. Display Recipe" +
"\n3. Scale Recipe" +
"\n4. Reset Quantities" +
"\n5. Clear Recipe" +
"\n6. Exit");
Console.Write("Enter the number:\n> ");
int user = int.Parse(Console.ReadLine());
//user selection
switch (user)
{
case 1:
addRecipe();
break;
case 2:
Recipe.printRecipe();
break;
case 3:
Recipe.scaleRecipe();
break;
case 4:
Recipe.resetQuantities();
break;
case 5:
Recipe.clearRecipe();
break;
case 6:
Console.WriteLine("Exiting...");
System.Environment.Exit(0);
break;
default:
Console.WriteLine("Enter a valid number... Try Again\n");
break;
}
}
}
#endregion
#region addRecipe
public static void addRecipe()
{
try
{
//name of the Recipe
Console.Write("Enter the name of the recipe:\n> ");
string recipeName = Console.ReadLine().ToLower();
Recipe.recipeName = recipeName;
//asking user for number of ingredients
Console.Write("Enter the number of ingredients:\n> ");
int numIngredients = int.Parse(Console.ReadLine());
//asking user for name, quantity & unit measurement of ingredient
for (int i = 0; i < numIngredients; i++)
{
Console.Write("Enter the name of ingredient {0}:\n> ", i + 1);
string name = Console.ReadLine();
Console.Write("Enter the quantity of {0}:\n> ", name);
double quantity = int.Parse(Console.ReadLine());
Console.Write("Enter the unit of measurement of {0}:\n> ", name);
string unit = Console.ReadLine();
//passing the variables to addIngredients method in Recipe class
Recipe.addIngredient(name, quantity, unit);
}
//asking user for steps to make the recipe
Console.Write("Enter the number of steps required:\n> ");
int numberSteps = int.Parse(Console.ReadLine());
//forloop for control how many steps there are
Console.WriteLine("Enter instructions for Steps: ");
for (int s = 0; s < numberSteps; s++)
{
Console.Write("{0}- ", s + 1);
Recipe.addStep(Console.ReadLine());
}
}
catch (Exception)
{
Console.WriteLine("Wrong input... try again");
}
}
#endregion
}
}