-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
198 lines (158 loc) · 7.53 KB
/
Copy pathProgram.cs
File metadata and controls
198 lines (158 loc) · 7.53 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
using System;
using System.Collections.Generic;
namespace Lab9
{
class Program
{
static void Main(string[] args)
{
List<string[]> studentList = MakeStudentList();
Console.WriteLine(studentList[2]);
//bool shouldContinue = false;
//do
//{
// Console.Clear();
// List<string[]> studentList = MakeStudentList();
// Console.WriteLine(studentList[2]);
// Dictionary<int, string[]> studentDicionary = MakeDictionary();
// int selectedStudent = AskUserForStudent();
// InterpretStudentData(selectedStudent, studentDicionary);
// shouldContinue = AskToContinue();
//} while (shouldContinue);
//Console.WriteLine("Alrighy then! See ya!");
}
static Dictionary<int, string[]> MakeDictionary()
{
string[] studentData = new string[3];
Dictionary<string, string[]> studentDictionary = new List<string[]>();
studentDictionary["name"] = new[] { "FavoriteColor", "Hometown", "FavoriteFood" };
studentDictionary["Bob"] = new[] { "Red", "Denver", "Pizza" };
studentDictionary["Frank"] = new[] { "Blue", "Tucson", "Burritos" };
studentDictionary["Debbie"] = new[] { "Green", "Flagstaff", "Carrots" };
studentDictionary["Sue"] = new[] { "Yellow", "Chicago", "Mayonnaise" };
studentDictionary["Mark"] = new[] { "Orange", "New York", "Tuna sandwich" };
studentDictionary["Damien"] = new[] { "Pink", "Boston", "Bread" };
studentDictionary["Angie"] = new[] { "Red", "Los Angles", "Pasta" };
studentDictionary["Carol"] = new[] { "Blue", "Anchorage", "Hummus" };
studentDictionary["Luke"] = new[] { "Blue", "Melbourne", "Cheese" };
studentDictionary["Stan"] = new[] { "Black", "Detroit", "Beans" };
studentDictionary["Karen"] = new[] { "Purple", "Seattle", "Chicken" };
studentDictionary["Amy"] = new[] { "Red", "Portland", "Eggs" };
studentDictionary["Derek"] = new[] { "Blue", "Nashville", "Toast" };
studentDictionary["John"] = new[] { "Yellow", "Jacksonville", "Cookies" };
studentDictionary["Ellen"] = new[] { "Blue", "Birmingham", "Cake" };
studentDictionary["Courtney"] = new[] { "Orange", "Aberdeen", "Egg rolls" };
studentDictionary["Fred"] = new[] { "Red", "London", "Rice" };
studentDictionary["Zed"] = new[] { "Green", "Toronto", "Baklava" };
studentDictionary["Mariah"] = new[] { "Blue", "Lima", "Candy" };
studentDictionary["Lauren"] = new[] { "Red", "Bismark", "Beef" };
return studentDictionary;
}
static List<string[]> MakeStudentList()
{
List<string[]> studentList = new List<string[]>();
studentList.add("name","Name", "Hometown", "FavoriteFood");
studentList.add("Bob", "Red", "Denver", "Pizza");
studentList.add("Frank", "Blue", "Tucson", "Burritos");
studentList.add("Debbie", "Green", "Flagstaff", "Carrots");
studentList.add("Sue", "Yellow", "Chicago", "Mayonnaise");
studentList.add("Mark", "Orange", "New York", "Tuna sandwich");
studentList.add("Damien", "Pink", "Boston", "Bread");
studentList.add("Angie", "Red", "Los Angles", "Pasta");
studentList.add("Carol", "Blue", "Anchorage", "Hummus");
studentList.add("Luke", "Blue", "Melbourne", "Cheese");
studentList.add("Stan", "Black", "Detroit", "Beans");
studentList.add("Karen", "Purple", "Seattle", "Chicken");
studentList.add("Amy", "Red", "Portland", "Eggs");
studentList.add("Derek", "Blue", "Nashville", "Toast");
studentList.add("John", "Yellow", "Jacksonville", "Cookies");
studentList.add("Ellen", "Blue", "Birmingham", "Cake");
studentList.add("Courtney", "Orange", "Aberdeen", "Egg rolls");
studentList.add("Fred", "Red", "London", "Rice");
studentList.add("Zed", "Green", "Toronto", "Baklava");
studentList.add("Mariah", "Blue", "Lima", "Candy");
studentList.add("Lauren", "Red", "Bismark", "Beef");
return studentList;
}
static int AskUserForStudent()
{
Console.WriteLine("Which student would you like to learn more about? (enter a number 1-20):");
int studentNumber = 0;
bool validNumber = false;
do
{
string input = Console.ReadLine();
if (int.TryParse(input, out studentNumber))
{
if (studentNumber <= 20 && studentNumber > 0)
{
validNumber = true;
}
else
{
validNumber = false;
Console.WriteLine("Hmm... that doesn't seem to be a student in this class... try another number, 1-20");
}
}
else
{
Console.WriteLine("That's not even a number... try that again.");
validNumber = false;
}
} while (!validNumber);
return studentNumber;
}
static void InterpretStudentData(int student, Dictionary<int, string[]> studentDicionary)
{
string[] studentData = studentDicionary[student];
bool validInput = false;
int desiredInfo = 0;
Console.WriteLine($"Ah yes, {studentData[0]}. What would you like to know about them? (hometown/favorite food)");
do
{
string userInput = Console.ReadLine().ToLower();
if (userInput == "hometown")
{
Console.WriteLine($"Oh, {studentData[0]}? They're from {studentData[1]}.");
return;
}
else if (userInput == "favorite food")
{
Console.WriteLine($"Oh, {studentData[0]}? Their favorite food is {studentData[2]}.");
return;
}
else
{
Console.WriteLine("Hmm... this is embarrising, I don't know what you mean. You'll need to type either 'hometown' or 'favorite food'.");
validInput = false;
}
} while (!validInput);
}
static bool AskToContinue()
{
bool shouldContinue = true;
bool validInput = false;
Console.WriteLine("Want to go again? (y/n)");
do
{
string input = Console.ReadLine().ToLower();
if(input == "y")
{
validInput = true;
shouldContinue = true;
}
else if (input == "n")
{
validInput = true;
shouldContinue = false;
}
else
{
Console.WriteLine("Well, that's not the answer I was looking for... type either 'y' or 'n' to continue");
validInput = false;
}
} while (!validInput);
return shouldContinue;
}
}
}