Beispiel #1
0
 /// <summary>
 /// Money being repaid
 /// </summary>
 /// <param name="coffemachine"></param>
 /// <returns></returns>
 public Coffemachine PayMoneyBack(Coffemachine coffemachine)
 {
     Console.WriteLine("You have {0} left, I will dispense them now", coffemachine.moneyInMachine);
     Console.ReadKey();
     coffemachine.moneyInMachine = 0;
     return(coffemachine);
 }
Beispiel #2
0
            /// <summary>
            /// Cups of coffee being dispensed
            /// </summary>
            /// <param name="coffemachine"></param>
            /// <returns></returns>
            public Coffemachine CupOfCoffee(Coffemachine coffemachine)
            {
                int counter = 0;

                while (moneyInMachine >= 5)
                {
                    if (amountOfCoffeeInPercent < 5)
                    {
                        Console.WriteLine("There's no more coffee in the machine, please fill it first");
                        Console.ReadKey();
                        coffemachine = coffemachine.PayMoneyBack(coffemachine);
                        return(coffemachine);
                    }
                    amountOfCoffeeInPercent = amountOfCoffeeInPercent - 5;
                    counter       += 1;
                    moneyInMachine = moneyInMachine - priceOfCoffee;
                    if (moneyInMachine < priceOfCoffee && moneyInMachine != 0)
                    {
                        coffemachine = coffemachine.PayMoneyBack(coffemachine);
                    }
                }
                Console.WriteLine("You have taken {0} cups of coffee", counter);
                Console.ReadKey();
                return(coffemachine);
            }
Beispiel #3
0
            /// <summary>
            /// Bressing button to buy coffee
            /// </summary>
            /// <param name="coffemachine"></param>
            /// <returns></returns>
            public Coffemachine ButtonPress(Coffemachine coffemachine)
            {
                if (coffemachine.amountOfCoffeeInPercent < 5)
                {
                    Console.WriteLine("There's no more coffee in the machine, please fill it first");
                    Console.ReadKey();
                    return(coffemachine);
                }
                bool run = true;

                while (run)
                {
                    Console.WriteLine("Please insert {0} coins per cup of coffee you want:", priceOfCoffee);
                    string input = Console.ReadLine();
                    try
                    {
                        int money = Convert.ToInt32(input);
                        moneyInMachine = money;
                        Console.WriteLine("You have successfully entered {0} into the machine", money);
                        Console.ReadKey();
                        run = false;
                        CupOfCoffee(coffemachine);
                    }
                    catch
                    {
                        Console.WriteLine("Please insert real money \n" +
                                          "(Type a number)");
                    }
                }
                return(coffemachine);
            }
Beispiel #4
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();
                    }
                }
            }
        }
Beispiel #5
0
 /// <summary>
 /// Check how much coffee is left in the machine
 /// </summary>
 /// <param name="coffemachine"></param>
 public void CurrentAmountOfCoffee(Coffemachine coffemachine)
 {
     Console.WriteLine("There is currently {0} percent of coffee in the machine", amountOfCoffeeInPercent);
     Console.ReadKey();
 }
Beispiel #6
0
 /// <summary>
 /// Filling machine with coffee
 /// </summary>
 /// <param name="coffemachine"></param>
 /// <returns></returns>
 public Coffemachine FillMachine(Coffemachine coffemachine)
 {
     amountOfCoffeeInPercent = 100;
     return(coffemachine);
 }