Exemple #1
0
 public bool RemoveVehicle(Garage <Vehicle> garage, Vehicle vehicle)
 {
     return(garage.Remove(vehicle));
 }
Exemple #2
0
        public static string AddMotorcycle(Garage <Vehicle> garage)
        {
            Motorcycle mc = new Motorcycle();

            Console.WriteLine("What is the Registration Number of the motorcycle?");
            Console.Write("> ");
            mc.RegNr = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What Colour is the motorcycle?");
            Console.Write("> ");
            mc.Colour = Console.ReadLine();

            mc.NbrOFSeats = EnvisInmat();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What fuel does the motorcycle use?");
            Console.Write("> ");
            mc.FuelType = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What engine does the motorcycle have?");
            Console.Write("> ");
            mc.TypOfEngine = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What model is the motorcycle?");
            Console.Write("> ");
            mc.TypOfModel = Console.ReadLine();

            bool y = true;

            while (y)
            {
                try
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("What is the cc?");
                    Console.Write("> ");
                    mc.CC = int.Parse(Console.ReadLine());
                    y     = false;
                }
                catch
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("Please enter a number");
                    Console.ReadKey();
                    y = true;
                }
            }

            Console.Clear();
            Scene.title();
            Console.WriteLine(mc.Stats());
            Console.ReadKey();

            garage.AddToArray(mc);

            return(mc.Stats());
        }
Exemple #3
0
        public static string AddTank(Garage <Vehicle> garage)
        {
            Tank tank = new Tank();

            Console.WriteLine("What is the Registration Number of the Tank?");
            Console.Write("> ");
            tank.RegNr = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What Colour is the tank?");
            Console.Write("> ");
            tank.Colour = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("How many seats are there in the tank?");
            Console.Write("> ");
            tank.NbrOFSeats = EnvisInmat();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What fuel does the tank use?");
            Console.Write("> ");
            tank.FuelType = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What engine does the tank have?");
            Console.Write("> ");
            tank.TypOfEngine = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What model is the tank?");
            Console.Write("> ");
            tank.TypOfModel = Console.ReadLine();

            bool y = true;

            Console.Clear();
            Scene.title();
            while (y)
            {
                try
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("What is the caliber?");
                    Console.Write("> ");
                    tank.Caliber = int.Parse(Console.ReadLine());
                    y            = false;
                }
                catch
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("Please enter a number");
                    Console.ReadKey();
                    y = true;
                }
            }

            Console.Clear();
            Scene.title();
            Console.WriteLine(tank.Stats());
            Console.ReadKey();

            garage.AddToArray(tank);

            return(tank.Stats());
        }
Exemple #4
0
        public static string AddBuss(Garage <Vehicle> garage)
        {
            Buss buss = new Buss();

            Console.WriteLine("What is the Registration Number of the Buss?");
            Console.Write("> ");
            buss.RegNr = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What Colour is the Buss?");
            Console.Write("> ");
            buss.Colour     = Console.ReadLine();
            buss.NbrOFSeats = EnvisInmat();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What fuel does the buss use?");
            Console.Write("> ");
            buss.FuelType = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What engine does the buss have?");
            Console.Write("> ");
            buss.TypOfEngine = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What model is the buss?");
            Console.Write("> ");
            buss.TypOfModel = Console.ReadLine();

            bool y = true;

            Console.Clear();
            Scene.title();

            while (y)
            {
                try
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("What is the Price of a fair?");
                    Console.Write("> ");
                    buss.FairPrice = int.Parse(Console.ReadLine());
                    y = false;
                }
                catch
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("Please enter a number");
                    Console.ReadKey();
                    y = true;
                }
            }

            Console.Clear();
            Scene.title();
            Console.WriteLine(buss.Stats());
            Console.ReadKey();

            garage.AddToArray(buss);

            return(buss.Stats());
        }
Exemple #5
0
        public static string AddBoat(Garage <Vehicle> garage)
        {
            Boat boat = new Boat();

            Console.WriteLine("What is the Registration Number of the boat?");
            Console.Write("> ");
            boat.RegNr = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What Colour is the boat?");
            Console.Write("> ");
            boat.Colour = Console.ReadLine();


            boat.NbrOFSeats = EnvisInmat();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What fuel does the boat use?");
            Console.Write("> ");
            boat.FuelType = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What engine does the boat have?");
            Console.Write("> ");
            boat.TypOfEngine = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What model is the boat?");
            Console.Write("> ");
            boat.TypOfModel = Console.ReadLine();

            bool y = true;

            Console.Clear();
            Scene.title();
            while (y)
            {
                try
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("What is the legnth of the boat?");
                    Console.Write("> ");
                    boat.Length = int.Parse(Console.ReadLine());
                    y           = false;
                }
                catch
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("Please enter a number");
                    Console.ReadKey();
                    y = true;
                }
            }


            Console.Clear();
            Scene.title();
            Console.WriteLine(boat.Stats());
            Console.ReadKey();

            garage.AddToArray(boat);

            return(boat.Stats());
        }
Exemple #6
0
        private static void FindVehicleByPropertiesMenu(Garage <Vehicle> garage)
        {
            string typeofvehicle  = "";
            string fabricant      = "";
            uint   numberofwheels = 0;
            string color          = "";
            uint   productionyear = 0;

            while (true)
            {
                var input = Utils.AskForNumber("\nSelect multiple properties one by one and then press 6 to filter from the parked vehicles"
                                               + "\n1. Type of vehicle"
                                               + "\n2. Fabricant"
                                               + "\n3. Number of wheels"
                                               + "\n4. Color"
                                               + "\n5. Production year"
                                               + "\n6. SEARCH AND FILTER"
                                               + "\n0. Go back to the garage menu"
                                               + "\n - - - - - - - - - - - - - - ");

                switch (input)
                {
                case 1:
                    var internalinput = Utils.AskForNumber("Filter by type of vehicle:"
                                                           + "\n1. Airplane"
                                                           + "\n2. Boat"
                                                           + "\n3. Bus"
                                                           + "\n4. Car"
                                                           + "\n5. Motorcycle");
                    if (internalinput == 1)
                    {
                        typeofvehicle = "Airplane";
                    }
                    else if (internalinput == 2)
                    {
                        typeofvehicle = "Boat";
                    }
                    else if (internalinput == 3)
                    {
                        typeofvehicle = "Bus";
                    }
                    else if (internalinput == 4)
                    {
                        typeofvehicle = "Car";
                    }
                    else if (internalinput == 5)
                    {
                        typeofvehicle = "Motorcycle";
                    }
                    else
                    {
                        Console.WriteLine("You haven't made any valid selection..");
                    }
                    break;

                case 2:
                    fabricant = Utils.AskForInput("Filter by the fabricant:");
                    break;

                case 3:
                    numberofwheels = Utils.AskForNumber("Filter by number of wheels:");
                    break;

                case 4:
                    color = Utils.AskForInput("Filter by color:");
                    break;

                case 5:
                    productionyear = Utils.AskForNumber("Filter by production year:");
                    break;

                case 6:
                    handler.FindVehicleOnProperties(garage, typeofvehicle, fabricant, numberofwheels, color, productionyear);
                    GarageMenu(garage);
                    break;

                case 0:
                    GarageMenu(garage);
                    break;

                default:
                    Console.WriteLine("Please make a valid selection!\n");
                    FindVehicleByPropertiesMenu(garage);
                    break;
                }
            }
        }
Exemple #7
0
        public static string AddAirplane(Garage <Vehicle> garage)
        {
            Airplane aplane = new Airplane();

            Console.WriteLine("What is the Registration Number of the Airplane?");
            Console.Write("> ");
            aplane.RegNr = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What Colour is the airplane?");
            Console.Write("> ");
            aplane.Colour = Console.ReadLine();

            aplane.NbrOFSeats = EnvisInmat();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What fuel does the airplane use?");
            Console.Write("> ");
            aplane.FuelType = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What engine does the airplane have?");
            Console.Write("> ");
            aplane.TypOfEngine = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What model is the airplane?");
            Console.Write("> ");
            aplane.TypOfModel = Console.ReadLine();

            bool y = true;

            while (y)
            {
                try
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("What is the wingspan?");
                    Console.Write("> ");
                    aplane.WingSpan = int.Parse(Console.ReadLine());
                    y = false;
                }
                catch
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("Please enter a number");
                    Console.ReadKey();
                    y = true;
                }
            }

            Console.Clear();
            Scene.title();
            Console.WriteLine(aplane.Stats());
            Console.ReadKey();

            garage.AddToArray(aplane);

            return(aplane.Stats());
        }
Exemple #8
0
 public void FindVehicleOnProperties(Garage <Vehicle> garage, string typeofvehicle = "", string fabricant = "", uint numberofwheels = 0, string color = "", uint productionyear = 0)
 {
     UI.ShowParkedVehicles(garage.FindVehicleOnProperties(typeofvehicle, fabricant, numberofwheels, color, productionyear));
 }
Exemple #9
0
        private static void CreateAndParkVehicleMenu(Garage <Vehicle> garage)
        {
            // Todo: check first if the garage is full??
            var input = Utils.AskForNumber("Which vehicle do you want to park?"
                                           + "\n1. Airplane"
                                           + "\n2. Boat"
                                           + "\n3. Bus"
                                           + "\n4. Car"
                                           + "\n5. Motorcycle"
                                           + "\n0. Go back to the garage menu"
                                           + "\n - - - - - - - - - - - - - - ");

            var promptRegNumber        = "Registration number:";
            var promptFabricant        = "Brand:";
            var promptNumberOfWheels   = "Number of wheels:";
            var promptColor            = "Color:";
            var promptYearOfProduction = "Year of production:";

            switch (input)
            {
            case 1:
                var airplane = new Airplane(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    numberofengines: Utils.AskForNumber("Number of engines:")
                    );
                handler.ParkVehicle(garage, airplane);
                CreateAndParkVehicleMenu(garage);
                break;

            case 2:
                var boat = new Boat(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    length: Utils.AskForNumber("Length:")
                    );
                handler.ParkVehicle(garage, boat);
                CreateAndParkVehicleMenu(garage);
                break;

            case 3:
                var bus = new Bus(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    numberofseats: Utils.AskForNumber("Number of seats:")
                    );
                handler.ParkVehicle(garage, bus);
                CreateAndParkVehicleMenu(garage);
                break;

            case 4:
                var car = new Car(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    fueltype: Utils.AskForInput("Fuel type:")
                    );
                handler.ParkVehicle(garage, car);
                CreateAndParkVehicleMenu(garage);
                break;

            case 5:
                var motorcycle = new Motorcycle(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    cylindervolume: Utils.AskForNumber("Cylinder volume:")
                    );
                handler.ParkVehicle(garage, motorcycle);
                CreateAndParkVehicleMenu(garage);
                break;

            case 0:
                GarageMenu(garage);
                break;

            default:
                Console.WriteLine("Please make a valid selection!\n");
                CreateAndParkVehicleMenu(garage);
                break;
            }
        }
Exemple #10
0
 public void ListVehicleTypes(Garage <Vehicle> garage)
 {
     UI.ShowVehiclesTypes(garage.ListVehicleTypes());
 }
Exemple #11
0
 public void ListParkedVehicles(Garage <Vehicle> garage)
 {
     UI.ShowParkedVehicles(garage.ListParkedVehicles());
 }
Exemple #12
0
        static public void TheChoice(int choice, Garage <Vehicle> garage)
        {
            List <Vehicle> vehicles = new List <Vehicle>();
            List <string>  answer   = new List <string>();

            switch (choice)
            {
            case 1:     //Parkera fordon¨- Lägga till fordon
                bool garageFull = garage.checkIsGarageFull();

                if (garageFull == true)
                {
                    Console.WriteLine("Tyvärr garaget är fullt - återkom senare");
                }
                else
                {
                    garage.addVehicle(parking());
                    Console.WriteLine("Nu är fordonet parkerat");
                }
                break;

            case 2:     //Köra ut fordon - Ta bort fordon
                foreach (Vehicle s in garage)
                {
                    Console.WriteLine(s);
                }
                Console.WriteLine();
                Console.WriteLine("Ange registreringsnumret på fordonet som ska köra ut");
                Console.WriteLine(garage.removeVehicle(Console.ReadLine()));
                break;

            case 3:    //Fordon i garaget
                Console.WriteLine("Det finns " + garage.numberOfVehicle() + " st fordon i garaget");
                Console.WriteLine();
                foreach (Vehicle s in garage)
                {
                    Console.WriteLine(s);
                }
                break;

            case 4:    //Se vilken typ av fordon i garaget
                string TheChoice = "7";
                while (int.Parse(TheChoice) < 0 || int.Parse(TheChoice) > 5)
                {
                    Console.WriteLine("Vilken typ av fordon vill du se i garaget?");
                    Console.WriteLine("1) Bil 2) Båt 3) Buss 4) Flygplan 5) Motorcykel");
                    TheChoice = Console.ReadLine();
                    if (int.Parse(TheChoice) > 5)
                    {
                        Console.WriteLine("Ange ett nummer mellan 1-5");
                    }
                }
                List <string> typ = new List <string>();
                typ = garage.numberOfSpecialVehicle(int.Parse(TheChoice));

                Console.WriteLine("Det finns " + typ.Count + " st forden av denna typ i garaget:");
                foreach (string s in typ)
                {
                    Console.WriteLine(s);
                }
                break;

            case 5:    //Sök efter fordon i garaget
                TheChoice = "7";
                while (int.Parse(TheChoice) < 0 || int.Parse(TheChoice) > 3)
                {
                    Console.WriteLine("Vad vill du söka efter i garaget?");
                    Console.WriteLine("1) Regnr 2) Färg 3) Antal hjul");
                    TheChoice = Console.ReadLine(); if (int.Parse(TheChoice) > 5)
                    {
                        Console.WriteLine("Ange ett nummer mellan 1-3");
                    }
                }
                if (TheChoice == "1")
                {
                    Console.WriteLine("Ange registreringnummer");
                    Console.WriteLine(garage.searchForRegnr(Console.ReadLine()));
                }
                else if (TheChoice == "2")
                {
                    Console.WriteLine("Ange färg på fordonet");
                    typ = garage.searchForColour(Console.ReadLine());
                    foreach (string s in typ)
                    {
                        Console.WriteLine(s);
                    }
                }
                else if (TheChoice == "3")
                {
                    Console.WriteLine("Ange antal hjul");
                    typ = garage.searchNrOfWheels(Console.ReadLine());
                    foreach (string s in typ)
                    {
                        Console.WriteLine(s);
                    }
                }
                break;

            default:
                break;
            }
            Console.WriteLine();
        }
Exemple #13
0
        public static void menu()
        {
            int c = 0;

            do
            {
                try
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("How many slots do you want in the garage?");
                    Console.Write("> ");
                    c = int.Parse(Console.ReadLine());
                    if (c <= 0)
                    {
                        Console.WriteLine("There has to be at least 1 slot in the garage");
                    }
                }
                catch
                {
                    Console.WriteLine("Ivalid input bitch");
                }
            } while (c <= 0);

            var garage = new Garage <Vehicle>(c);

            while (true)
            {
                Console.Clear();
                Scene.title();
                Console.WriteLine("\n Welcome to the Garage"
                                  + "\nPress 1 to add a vehicles to it"
                                  + "\nPress 2 to take out a vehicle from your garage"
                                  + "\nPress 3 to view your garage"
                                  + "\nPress 4 to search"
                                  + "\nPress 0 to exit");
                Console.Write("> ");

                char input = ' ';
                try
                {
                    input = Console.ReadLine()[0];
                }
                catch
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("Please enter input");
                }

                switch (input)
                {
                case '1':
                    Creation.menu(garage);
                    break;

                case '2':
                    Remove.FromArray(garage);
                    break;

                case '3':
                    ViewGarage.Show(garage, c);
                    break;

                case '4':
                    Searching.ForSugerMan(garage);
                    break;

                case 't':
                    TestGarage.test(garage, c);
                    break;

                case '0':
                    return;
                }
            }
        }
Exemple #14
0
        public void GarageFunctions(Garage <Vehicle> garage)
        {
            Console.Clear();
            if (garage != null)
            {
                while (true)

                {
                    Console.WriteLine("Please navigate through the menu by inputting your choice:\n"
                                      + "\n 1: Print out all parked vehicles "
                                      + "\n 2: Print out types of vehicles and number of each that exsist in Garage"
                                      + "\n 3: Park a vehicle in Garage"
                                      + "\n 4: Take out a vehicle from Garage"
                                      + "\n 5: Find a vehicle with registering number"
                                      + "\n 6: Find vehicles with specific properties"
                                      + "\n 7: Garage capacity."
                                      + "\n 8: Back to main Menu"
                                      );

                    char input = ' '; //Creates the character input to be used with the switch-case below.

                    try
                    {
                        input = Console.ReadLine()[0]; //Tries to set input to the first char in an input line
                    }
                    catch (IndexOutOfRangeException)   //If the input line is empty, we ask the users for some input.
                    {
                        Console.Clear();
                        Console.WriteLine("Please enter some input!");
                    }

                    switch (input)
                    {
                    case '1':

                        PrintOutAllVehicles();
                        break;

                    case '2':

                        VehicleTypeNumbers();
                        break;

                    case '3':

                        ParkVehicle();
                        break;

                    case '4':

                        TakeOutVehicle();
                        break;

                    case '5':

                        FindByRegNumber();
                        break;

                    case '6':

                        FindByProperties();
                        break;

                    case '7':

                        Console.WriteLine($"There is {GarageEmptyPlace(garage)} empty place in garage");
                        break;

                    case '8':
                        return;

                    default:
                        Console.WriteLine("Please enter some valid input ( 1, 2, 3, 4, 5, 6, 7 )");
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine("You should first create a garage then use its functions.");
            }
        }