Beispiel #1
0
        static void Main(string[] args)
        {
            bool coffeeMachineIsRunning = false;
            bool pottedPlantIsRunning   = false;
            bool engineIsRunning        = false;
            bool isRunning = true;

            while (isRunning)
            {
                Console.WriteLine("To enter the coffee machine, type cm \n" +
                                  "To enter the potted plant, type pp \n" +
                                  "To enter the engine, type e \n" +
                                  "Or type exit to quit");
                string input = Console.ReadLine();
                switch (input.ToLower())
                {
                case "cm":
                    coffeeMachineIsRunning = true;
                    break;

                case "pp":
                    pottedPlantIsRunning = true;
                    break;

                case "e":
                    engineIsRunning = true;
                    break;

                case "exit":
                    isRunning = false;
                    break;

                default:
                    Console.WriteLine("I didn't understand, please try again.");
                    break;
                }


                while (pottedPlantIsRunning)
                {
                    PottedPlant pottedPlant = new PottedPlant();
                    pottedPlant.numberOfLeaves = 127;
                    Console.Clear();
                    bool isPottedPlantRunning = true;
                    while (isPottedPlantRunning)
                    {
                        Console.WriteLine("What do you want to do? \n" +
                                          "If you want to look at the plant, write look \n" +
                                          "If you want to count the number of leaves, type count \n" +
                                          "If you want to see if the plant is real, type check \n" +
                                          "If you want to see if the POTTED plant is in a pot, type pot\n" +
                                          "If you want to water the plant, type water");
                        input = Console.ReadLine();
                        switch (input.ToLower())
                        {
                        case "look":
                            pottedPlant.Lookatplant();;
                            break;

                        case "count":
                            pottedPlant.CountNumberOfLeaves();
                            break;

                        case "check":
                            pottedPlant.IsReal();
                            break;

                        case "pot":
                            pottedPlant.IsInPot();
                            break;

                        case "water":
                            pottedPlant.IsPlantWatered();
                            break;

                        default:
                            Console.WriteLine("I'm sorry I don't understand");
                            break;
                        }
                        Console.Clear();
                    }
                }

                while (engineIsRunning)
                {
                    Console.Clear();
                    Engine engine = new Engine();
                    engine.brand          = "Volvo";
                    engine.cylinders      = 6;
                    engine.engineCapacity = 2.4;
                    bool isEngineRunning = true;
                    while (isEngineRunning)
                    {
                        Console.WriteLine("What do you want to do? \n" +
                                          "If you want to start the engine write start \n" +
                                          "If you want to move the engine write move \n" +
                                          "If you want to see if the engine needs cleaning write clean \n" +
                                          "If you want to fill the engine with fuel write fuel \n" +
                                          "If you want information about the engine write info");
                        input = Console.ReadLine();

                        switch (input.ToLower())
                        {
                        case "start":
                            engine.EngineStart(engine);
                            break;

                        case "move":
                            engine.Movable();
                            break;

                        case "clean":
                            engine.NeedCleaning();
                            break;

                        case "fuel":
                            engine.FillWithFuel(engine);
                            break;

                        case "info":
                            engine.InformationAboutEngine();
                            break;

                        default:
                            Console.WriteLine("I'm sorry I don't understand");
                            break;
                        }
                        Console.Clear();
                    }
                }



                while (coffeeMachineIsRunning)
                {
                    Coffemachine coffemachine = new Coffemachine();

                    Console.WriteLine("Please set the cost of coffee");
                    input = Console.ReadLine();
                    coffemachine.PriceOfCoffee(input);
                    bool isRunningCM = true;
                    while (isRunningCM)
                    {
                        Console.Clear();
                        Console.WriteLine("Do you want a cup of coffee? Then write coffee \n" +
                                          "Do you want to know how much coffee is currently in the machine? Then write status \n" +
                                          "Do you want to fill up the machine? Then write fill \n" +
                                          "");
                        input = Console.ReadLine();

                        switch (input.ToLower())
                        {
                        case "coffee":
                            coffemachine = coffemachine.ButtonPress(coffemachine);
                            break;

                        case "status":
                            coffemachine.CurrentAmountOfCoffee(coffemachine);
                            break;

                        case "fill":
                            coffemachine = coffemachine.FillMachine(coffemachine);
                            break;

                        case "hit":
                            coffemachine.Hit();
                            break;

                        default:
                            Console.WriteLine("I'm sorry I didn't understand that. Please try again.");
                            break;
                        }
                        Console.Clear();
                    }
                }
            }
        }