static void Main(string[] args) { Elevator elevator = new Elevator(); Console.WriteLine("You are in Dynamo's elevator."); Console.WriteLine("Exit the elevator by typing exit."); int floor; bool result; string line; while (true) { Console.WriteLine(); Console.Write("Give a new floor number (1-5) > "); line = Console.ReadLine(); result = int.TryParse(line, out floor); if (result) { elevator.Floor = floor; Console.WriteLine("Elevator is now in floor: " + elevator.Floor); } else if (line.ToLower() == "exit") { Console.WriteLine("Bye!"); break; } else { Console.WriteLine("You didn't give a number!"); Console.WriteLine("Elevator is now in floor: " + elevator.Floor); } } }
static void Main(string[] args) { Elevator elevator = new Elevator(); do { Console.WriteLine("Elevator is in room: " + elevator.Height); Console.Write("Give floor number (1-5): "); elevator.Height = int.Parse(Console.ReadLine()); } while (true); }
static void Main(string[] args) { int valinta = 0; Elevator elevator = new Elevator(); do { Console.WriteLine("Elevator is now in floor : " + elevator.ToString()); Console.WriteLine("Give a new floor number (1-5) "); valinta = int.Parse(Console.ReadLine()); elevator.Floor = valinta; } while (valinta != 999); }
static void Main(string[] args) { Console.WriteLine("You're in the elevator!"); Elevator elevator = new Elevator(); do { Console.Write("You are at floor " + elevator.Floor + " Press (1-5)"); elevator.Floor = int.Parse(Console.ReadLine()); } while (true); }
static void Main(string[] args) { int floor; Elevator elevator = new Elevator(); Console.Write("Give a new floor number (1-5) > " ); string line = Console.ReadLine(); bool result = int.TryParse(line, out floor); elevator.Floor = floor; if (result) { Console.WriteLine("Elevator is now in floor : " + elevator.Floor); } }
static void Main(string[] args) { int luku = 1; Console.WriteLine("Voit lopettaa painamalla 20"); Console.Write("Anna kerros mihin haluat menna (1-5) : "); luku = int.Parse(Console.ReadLine()); do { Elevator elevator = new Elevator(); elevator.Floor = luku; Console.WriteLine("Hissi on kerroksessa: " + elevator.Floor); Console.WriteLine("\nVoit lopettaa painamalla 20"); Console.Write("Anna kerros mihin haluat menna (1-5) : "); luku = int.Parse(Console.ReadLine()); } while (luku != 20); }
static void Main(string[] args) { Elevator elevator = new Elevator(); bool result; do { // get elevator floor Console.WriteLine("Elevator is now in floor : " + elevator.Floor); // get a new floor Console.Write("Give a new floor number (1-5) > "); String line = Console.ReadLine(); int floor; result = Int32.TryParse(line, out floor); if (result) { // try to set a new floor elevator.Floor = floor; } } while (result); Console.WriteLine("Press enter key to continue..."); Console.ReadLine(); }