static void Main(string[] args) { Hissi hissi = new Hissi(); hissi.Floornumber = 1; bool result; do { int floor; Console.WriteLine("The elevator is in " + hissi.Floornumber + " floor"); Console.WriteLine("Please select a floor (1-5) or press 0 to exit"); string line = Console.ReadLine(); result = int.TryParse(line, out floor); if (result == true) { hissi.Floornumber = floor; } else { Console.WriteLine("please select a number instead of alphabet next time"); } }while (result == true); }
static void Main(string[] args) { Hissi hissi = new Hissi(); do { Console.WriteLine("Elevator is now on floor " + hissi.Floor); Console.WriteLine("Give floor number (1-5) > "); string line = Console.ReadLine(); hissi.Floor = int.Parse(line); } while (hissi.Floor != 0); }
static void Main(string[] args) { Hissi hissi = new Hissi(); int luku; hissi.Kerros = 1; do { Console.Write("Anna kerros 1-5, avaa ovet painamalla 0 > "); string line = Console.ReadLine(); luku = int.Parse(line); hissi.Kerros = luku; Console.WriteLine("Hissi on nyt kerroksessa " + hissi.Kerros); } while (luku != 0); Console.WriteLine("Astu ulos hissistä"); }