-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
50 lines (47 loc) · 1.48 KB
/
Program.cs
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
using System;
using products.bread;
using products.pastry;
using System.Threading;
namespace Bakery
{
public class Counter
{
public static void Main()
{
Bread breadStock = new Bread(30, 5);
Pastry PastryStock = new Pastry(30, 2, 5);
Console.WriteLine("Menu:\n Bread: $" + Bread.Price + "\n Pastries: $" + Pastry.Price);
Console.WriteLine("\nEnter Order:");
Console.WriteLine("\nHow many loaves of bread would you like?");
string breadOrder = Console.ReadLine();
bool isBreadInt = int.TryParse(breadOrder, out int numBread);
Console.WriteLine("How many pastries would you like?");
string pastryOrder = Console.ReadLine();
bool isPastryInt = int.TryParse(pastryOrder, out int numPastry);
if(!isBreadInt || !isPastryInt)
{
Console.WriteLine("\nPlease enter a number\n");
Thread.Sleep(1000);
Main();
return;
}
if (numBread >= 1 && isBreadInt)
{
Console.WriteLine("Your order comes to,\n Bread: $" + Bread.buyLoaves(numBread));
}
if (numPastry >= 1 && isPastryInt)
{
Console.WriteLine(" Pastry: $" + Pastry.buyPastry(numPastry));
}
Console.WriteLine(Total(Bread.OrderPrice, Pastry.OrderPrice));
Console.WriteLine("\nPress any key to exit");
Console.ReadKey();
return;
}
public static string Total(int bread, int pastry)
{
int total = bread + pastry;
return " Total: $" + total;
}
}
}