int switcher = 0;
int currentFloor = -1;
while (true)
{
Console.WriteLine("Elevator \nFloor 0: Entre \nFloor 1: Sellingarea \nFloor 2: IT-Department \nFloor 3: Project-management \nFloor 4: Boss");
switcher = ReadInput();
if (currentFloor != switcher)
Switch(switcher);
else
ErrorMsg(currentFloor);
currentFloor = switcher;
}
static void ErrorMsg(int currentFloor)
{
Console.Clear();
Console.WriteLine($"You are already at floor {currentFloor}");
}
static int ReadInput()
{
if (!int.TryParse(Console.ReadLine(), out int switcher) || switcher < 0 || switcher > 4)
Console.WriteLine("Type a button between 0-4 to get to the floors");
return switcher;
}
static void RunElevator(string floor)
{
for (int i = 1; i < 10; i++)
{
Console.WriteLine(i + "Seconds");
Thread.Sleep(500);
}
Console.Clear();
Console.WriteLine($"Welcome to {floor}");
}
static void Switch(int switcher)
{
switch (switcher)
{
case 0:
RunElevator("Entre");
break;
case 1:
RunElevator("Selling area");
break;
case 2:
RunElevator("IT-Department");
break;
case 3:
RunElevator("Project-managment");
break;
case 4:
RunElevator("the boss office");
break;
}
}