Opdracht 3c
This commit is contained in:
parent
c65fcf6a22
commit
a53ceb2def
@ -11,15 +11,15 @@ namespace OOP_Opdracht_CSharp_Alfa_2022
|
|||||||
Console.WriteLine("Hello World!");
|
Console.WriteLine("Hello World!");
|
||||||
Opdracht2();
|
Opdracht2();
|
||||||
Opdracht3();
|
Opdracht3();
|
||||||
|
Opdracht3c();
|
||||||
}
|
}
|
||||||
static void Opdracht2()
|
static void Opdracht2()
|
||||||
{
|
{
|
||||||
Game game = new classes.Game("game"); // Init publisher class instance
|
Game game = new classes.Game("game"); // Init publisher class instance
|
||||||
var someRecord = game.find(1); // find specific record
|
var someRecord = game.find(1); // find specific record
|
||||||
Console.WriteLine($"Record 1 is equal to {someRecord}");
|
Console.WriteLine($"Record 1 is equal to {someRecord}");
|
||||||
|
|
||||||
// Get the full dictionary and loop over each record
|
// Get the full dictionary and loop over each record
|
||||||
var games = game.getTableData();
|
Dictionary<int, String> games = game.getTableData();
|
||||||
Console.WriteLine("Outputting Table Contents:");
|
Console.WriteLine("Outputting Table Contents:");
|
||||||
foreach (KeyValuePair<int, string> entry in games)
|
foreach (KeyValuePair<int, string> entry in games)
|
||||||
{
|
{
|
||||||
@ -42,5 +42,37 @@ namespace OOP_Opdracht_CSharp_Alfa_2022
|
|||||||
}
|
}
|
||||||
Console.WriteLine($"Trying to fetch KeyValue with invalid id 5 {publisher.find(7)}"); // Attempt to find invalid record and output to Console
|
Console.WriteLine($"Trying to fetch KeyValue with invalid id 5 {publisher.find(7)}"); // Attempt to find invalid record and output to Console
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void Opdracht3c()
|
||||||
|
{
|
||||||
|
Publisher publisher = new Publisher("publisher"); // Init publisher class instance
|
||||||
|
Dictionary<String, Model> tableDict = new Dictionary<string, Model>();
|
||||||
|
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
String input;
|
||||||
|
// Ask user if they want to request a specific entry
|
||||||
|
Console.WriteLine("Would you like to look up a record? [Y/n]");
|
||||||
|
input = Console.ReadLine();
|
||||||
|
// Allow user to escape the loop
|
||||||
|
if(input == "n" || input == "N" || input == "no" || input == "NO" || input == "q"){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Console.WriteLine("Please enter the id of the publisher you wish to look up");
|
||||||
|
input = Console.ReadLine();
|
||||||
|
int id = -1;
|
||||||
|
try{
|
||||||
|
id = int.Parse(input);
|
||||||
|
}
|
||||||
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Invalid input for id. Please enter a positive Integer value (Whole number)");
|
||||||
|
}
|
||||||
|
if(id >= 0){
|
||||||
|
Console.WriteLine($"Record {id} is equal to {publisher.find(id)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user