From 6823d35f816309bc3dc9a6734f1073299645113b Mon Sep 17 00:00:00 2001 From: Andreas Date: Thu, 8 Dec 2022 13:02:30 +0100 Subject: [PATCH] implemented find method --- .../OOP-Opdracht-CSharp-Alfa-2022/classes/Game.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/classes/Game.cs b/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/classes/Game.cs index dcc5f58..f3cea30 100644 --- a/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/classes/Game.cs +++ b/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/classes/Game.cs @@ -10,15 +10,20 @@ namespace OOP_Opdracht_CSharp_Alfa_2022.classes // Define class members private SqlConnection connection; - private Dictionary table_data; - private KeyValuePair record; + private Dictionary table_data; + private KeyValuePair record; // Define methods - public KeyValuePair find() + public KeyValuePair find(int id = 1) { - - return new KeyValuePair(); + KeyValuePair record = new KeyValuePair(0, null); + if (table_data.ContainsKey(id)) + { + record = new KeyValuePair(id, table_data.GetValueOrDefault(id)); + } + this.record = record; + return record; } public Game()