public int getData() { string input; bool validation; int myValue; var alert = new ColorAlerts(); do { alert.colorWhite(); Console.WriteLine("Adj meg egy pozitív egész számot:"); input = Console.ReadLine(); validation = int.TryParse(input, out myValue); if (myValue <= 0 && validation == true) { alert.colorRed(); Console.WriteLine($"Hiba! A megadott értéknek nagyobbnak kell lennie, mint 0!"); } else if (validation == false) { alert.colorRed(); Console.WriteLine($"Hiba! A megadott érték csak szám lehet!"); } } while (myValue <= 0 || validation == false); alert.colorGreen(); Console.WriteLine($"\nA tömböd elemeinek száma: {myValue}\n"); alert.colorWhite(); return(myValue); }
public void start() { bool run = true; while (run) { var color = new ColorAlerts(); var print = new PrintData(); print.writeAll(); color.colorGreen(); Console.WriteLine("Újraindításhoz: Y + ENTER"); color.colorRed(); Console.WriteLine("Befejezéshez: tetszőleges gomb + ENTER"); color.colorWhite(); var a = Console.ReadLine(); if (a.ToUpper() == "Y") { run = true; } else { run = false; } } }