public static void KundeMenu() //Kundemenu valg som fører videre til andre metoder { Checkfilter menuChoices = pressedKey => pressedKey != 'A' && pressedKey != 'S' && pressedKey != 'D' && pressedKey != 'F' && pressedKey != 'Q'; bool inMenu = true; while (inMenu) { listeAfKunder = Kunde.GetKunderList(); listeAfKonti = Konto.GetKontiList(); DrawKunde(); switch (EvaluateInput(menuChoices)) { case 'A': CreateKunde(); break; case 'S': DeleteKunde(); break; case 'D': SearchKunde(); break; case 'F': Kontooversigt(); break; case 'Q': inMenu = false; break; } } }
public static char Start() //Menu input for hovedmenu { Checkfilter menuChoices = pressedKey => pressedKey != 'A' && pressedKey != 'S' && pressedKey != 'Q'; DrawStart(); return(EvaluateInput(menuChoices)); }
/// <summary> /// Tager en bool delegate af typen Checkfilter(char c);. Det er et filter for at bestemme tilladte taster for Console.Readkey input. /// <para></para> /// Eksempel: Checkfilter menuChoices = pressedKey => pressedKey != 'A' && pressedKey != 'S' && pressedKey != 'Q'; /// </summary> /// <param name="filter"></param> /// <returns></returns> //Checkfilter menuChoices = pressedKey => pressedKey != 'A' && pressedKey != 'S' && pressedKey != 'Q'; private static char EvaluateInput(Checkfilter filter) { char button; int inputLeft = Console.CursorLeft, inputTop = Console.CursorTop; do { Console.SetCursorPosition(inputLeft, inputTop); button = Console.ReadKey().KeyChar; button = char.ToUpper(button); } while (filter(button)); return(button); }
private static void SletKonto() { Checkfilter yesNo = pressedKey => pressedKey != 'Y' && pressedKey != 'N'; int kontoNr; Console.Clear(); Console.WriteLine(); Console.Write("\t\tIndtast kontonummer: "); kontoNr = Convert.ToInt32(Console.ReadLine()); Konto denneKonto = listeAfKonti.Find(k => k.Kontonummer == kontoNr); Console.WriteLine("Er du sikker du vil slette denne konto? (Y/N): "); if (EvaluateInput(yesNo) == 'Y') { denneKonto.RemoveKonto(); } }
private static void DeleteKunde() //UI for slet en kunde { Checkfilter yesNo = pressedKey => pressedKey != 'Y' && pressedKey != 'N'; int kundeNr; Console.Clear(); Console.WriteLine(); Console.Write("\t\tIndtast kundeummer: "); kundeNr = Convert.ToInt32(Console.ReadLine()); Kunde denneKunde = listeAfKunder.Find(k => k.Kundenummer == kundeNr); Console.WriteLine("Er du sikker du vil slette denne kunde? (Y/N): "); if (EvaluateInput(yesNo) == 'Y') { denneKunde.RemoveKunde(); } }
public static void KontoMenu() //Menuen for Konto { Checkfilter menuChoices = pressedKey => pressedKey != 'A' && pressedKey != 'S' && pressedKey != 'D' && pressedKey != 'F' && pressedKey != 'G' && pressedKey != 'Q'; bool inMenu = true; while (inMenu) { listeAfKonti = Konto.GetKontiList(); //Loading af lister listeAfTransaktioner = Transaktion.GetTransaktionerList(); DrawKonto(); switch (EvaluateInput(menuChoices)) //Switch til Metoder { case 'A': OpretKonto(); break; case 'S': SletKonto(); break; case 'D': VisSaldo(); break; case 'F': IndsætHæv(); break; case 'G': VisTransaktioner(); break; case 'Q': inMenu = false; break; } } }