-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
142 lines (120 loc) · 3.42 KB
/
Copy pathProgram.cs
File metadata and controls
142 lines (120 loc) · 3.42 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
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
class Program
{
static List<RentalOffice> rentalOffices = new List<RentalOffice>();
public Random rand = new Random();
public static void IterateDays(int days)
{
for (int i = 0; i < rentalOffices.Count; i++)
{
for (int j = 0; j < rentalOffices[i].cars.Count; j++)
{
rentalOffices[i].cars[j].ChangeValues(days);
}
}
}
public static void ChooseRentalOffice(int idNum)
{
for (int i = 0; i < rentalOffices.Count; i++)
{
if (rentalOffices[i].IdNumber == idNum)
{
rentalOffices[i].SecondMenu();
break;
}
}
}
public static int CalcTotalRevenue()
{
int result = 0;
for (int i = 0; i < rentalOffices.Count; i++)
{
result += rentalOffices[i].CalcRevenue();
}
return result;
}
public static void PresentAllCars()
{
for (int i = 0; i < rentalOffices.Count; i++)
{
rentalOffices[i].PresentCars();
}
}
public static void PresentAllOffices()
{
for (int i = 0; i < rentalOffices.Count; i++)
{
Console.WriteLine($"Kontor nummer: {rentalOffices[i].IdNumber}");
}
}
public static void SetUpOffices()
{
for (int i = 0; i < 30; i++)
{
rentalOffices.Add(new RentalOffice(i));
}
}
public static int Input()
{
int result = 0;
bool loop = false;
do
{
if (int.TryParse(Console.ReadLine(), out result))
{
loop = false;
}
else
{
Console.Beep(900, 100);
Thread.Sleep(70);
Console.Beep(400, 650);
loop = true;
}
} while (loop);
return result;
}
static public void StartMenu()
{
bool loop = true;
do
{
Console.WriteLine("\tVad vill du göra?\n" +
"\t1. Välj hyreskontor.\n" +
"\t2. Se totala intäkter för alla kontor.\n" +
"\t3. Visa lista över alla bilar.\n" +
"\t4. Gör en tidsresa.\n" +
"\t5. Avsluta programmet.");
switch (Input())
{
case 1:
PresentAllOffices();
Console.WriteLine("Skriv in kontorets id-nummer.");
ChooseRentalOffice(Input());
break;
case 2:
Console.WriteLine($"Totala intäkter är: {CalcTotalRevenue():C0}");
break;
case 3:
PresentAllCars();
break;
case 4:
Console.WriteLine("Hur många dagar frammåt i tiden vill ni resa?");
IterateDays(Input());
break;
case 5:
loop = false;
break;
}
} while (loop);
}
public static void Main(string[] args)
{
CultureInfo.CurrentCulture = new CultureInfo("sv-SE", false);
SetUpOffices();
StartMenu();
}
}