A
A
Alexa Ponamareva2021-10-28 10:43:59
C++ / C#
Alexa Ponamareva, 2021-10-28 10:43:59

The code breaks, what's the return?

I originally had to make an elevator simulation program, I don’t understand what the problem is and how to fix the code ...

using System;
namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            Elevator el = new Elevator();
            el.TunrOn();
        }
    }
    class Elevator
    {
        int currentFloor = 0;
        int capacity = 200;
        int maxFloor = 18;
        private bool isTurnedOn = false;

        public bool GetState()
        {
            return isTurnedOn;
        }
        public int Move(int toFloor)
        {
            string input;
            Elevator el = new Elevator();
            Console.WriteLine("\n Выберите действие: \n C - вызвать лифт \n E - выйти из программы \n ");
            while (el.GetState())
            {
                input = Console.ReadLine();
                switch (input.ToLower())
                {
                    case "custom":
                        Console.WriteLine("Введите номер желаемого этажа");
                        int floor = Convert.ToInt32(Console.ReadLine());
                        el.IsAllowableFloor(floor);
                        break;
                    case "exit":
                        el.ExtElevator();
                        break;
                    default:
                        Console.WriteLine("Введите команду из предложенных ( \"Custom\", \"Off\")");
                        break;
                }
            }
        }
        public int IsAllowblewWeight(int weight)
        {
            if (capacity > 200)
            {
                Console.WriteLine("Вес больше 200");
            }
        }
        public int IsAllowableFloor(int floor)
        {
            if (maxFloor > 18 && maxFloor > -1)
            {
                Console.WriteLine("Такого этажа не существует");
            }
        }
        public void TunrOn()
        {
            if (!isTurnedOn)
            {
                Console.WriteLine("Вы вызвали лифт. Текущий этаж " + currentFloor);
                isTurnedOn = true;
            }
        }
        public void ExtElevator()
        {
            if (isTurnedOn)
            {
                Console.WriteLine("Выход из лифта");
                isTurnedOn = false;
            }
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AndromedaStar, 2021-10-28
@didiwka

All methods must return void.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question