Пример #1
0
 public InnerSubInterfaceRentals(Fleet fleet, CRM crm) : base(fleet, crm)
 {
 }
Пример #2
0
        // Method to modify the vehicle fields, either with default or full fields
        private void ModifyVehicle(Vehicle vehicle, bool fullfields = false)
        {
            Console.Clear();

            string subMenu;

            if (fullfields)
            {
                subMenu = "### Modify Full Vehicle Submenu ###\n";
            }
            else
            {
                subMenu = "### Modify Default Vehicle Submenu ###\n";
            }

            Console.WriteLine(subMenu);
            Console.WriteLine("Please fill the following fields to modify (fields with * are required)\n");
            // Set the Registration to 000NUL (hinting null), in case the registration number wants to be retained and only the other fields
            // are to be modified. We set the Rego to null so that the validation doesnt prompt an error that registration wanting
            // to be retained already exists. If the Registration is retained, there is still unique registrations in the list
            vehicle.registration = "000NUL";
            // Save the changed registration value in case operator decideds to retain the same Registration in the modification menu.
            Fleet.SaveVehiclesToFile();
            // Mandatory attributes for default
            RegistrationValidInput();
            vehicle.registration = registration;
            GradeValidInput();
            vehicle.grade = Grade;
            Console.Write("Make*: ");
            make         = StringToTitleCase(Console.ReadLine());
            vehicle.make = make;
            Console.Write("Model*: ");
            model         = StringToTitleCase(Console.ReadLine());
            vehicle.model = model;
            YearValidInput();
            vehicle.year = int.Parse(year);
            // If full fields is true, modify the full vehicle including non-mandatory attributes
            if (fullfields)
            {
                NumSeatsValidInput();
                vehicle.numSeats = NumSeats;
                TransmissionValidInput();
                vehicle.transmission = Transmission;
                FuelValidInput();
                vehicle.fuel = Fuel;
                BoolValidInput("GPS");
                vehicle.GPS = GPS;
                BoolValidInput("SunRoof");
                vehicle.sunRoof = SunRoof;
                DailyRateValidInput();
                vehicle.dailyRate = DailyRate;
                Console.Write("Colour*: ");
                colour         = StringToTitleCase(Console.ReadLine());
                vehicle.colour = colour;
            }
            Console.Write("\nSuccessfully modified vehicle '{0}' to vehicle '{1} {2} {3} {4}'",
                          regoToModify, registration, make, model, year);
            // Save the new modified vehicle to the file
            Fleet.SaveVehiclesToFile();
            LastMRRCscreen(() => SubMenu("Fleet"), () => ModifyVehicleSubmenu());
        }
Пример #3
0
 public InnerSubInterfaceFleet(Fleet fleet, CRM crm) : base(fleet, crm)
 {
 }
Пример #4
0
        // Method which reads and validates user input and adds the default vehicle to the fleet csv file
        private void AddDefaultVehicle(string GradeOption = "None", bool clear = true, bool GradeProvided = false)
        {
            if (clear)
            {
                Console.Clear();
            }
            VehicleGradeOption("Default", GradeProvided, GradeOption);
            Console.WriteLine("Please fill the following fields (fields with * are required)\n");
            RegistrationValidInput();
            // If the grade of the vehicle has not been pre-selected (i.e. commercial), then ask for the grade
            if (!GradeProvided)
            {
                GradeValidInput();
            }
            Console.Write("Make*: ");
            make = StringToTitleCase(Console.ReadLine());
            Console.Write("Model*: ");
            model = StringToTitleCase(Console.ReadLine());
            YearValidInput();
            // If the grade is provided, create and instantiate vehicle object from the othervehicles class.
            if (GradeProvided)
            {
                // Assign initial value to new vehicle as null
                Vehicle newVehicle = null;

                // Depending on the grade option, re-assign newvhicle instance by instatiating the grade class
                if (GradeOption == "Economy")
                {
                    newVehicle = new EconomyVehicle(registration, Grade, make, model, int.Parse(year));
                }
                else if (GradeOption == "Family")
                {
                    newVehicle = new FamilyVehicle(registration, Grade, make, model, int.Parse(year));
                }
                else if (GradeOption == "Luxury")
                {
                    newVehicle = new LuxuryVehicle(registration, Grade, make, model, int.Parse(year));
                }
                else if (GradeOption == "Commercial")
                {
                    newVehicle = new CommercialVehicle(registration, Grade, make, model, int.Parse(year));
                }
                // Add the new vehicle providing that registration doesnt already exist
                if (Fleet.AddVehicle(newVehicle))
                {
                    Console.Write("\nSuccessfully added new vehicle '{0} - {1} {2} {3}' and added to vehicle list", registration, grade, model, make);
                    Fleet.SaveVehiclesToFile();
                }
                // If user presses any key, prompt the end of the menu
                LastMRRCscreen(() => SubMenu("Fleet"), () => NewVehicleSubMenu());
            }
            // Otherwise, create and instatiate standard vehicle object from the vehicles class
            else
            {
                Vehicle newVehicle = new Vehicle(registration, Grade, make, model, int.Parse(year));
                // Add the new vehicle providing that registration doesnt already exist
                if (Fleet.AddVehicle(newVehicle))
                {
                    Console.Write("\nSuccessfully added new vehicle '{0} - {1} {2} {3}' and added to vehicle list", registration, grade, model, make);
                    Fleet.SaveVehiclesToFile();
                }
                // If user presses any key, prompt the end of the menu
                LastMRRCscreen(() => SubMenu("Fleet"), () => NewVehicleInnerSubMenu(GradeOption, () => AddDefaultVehicle(GradeOption), () => AddDefaultVehicle(GradeOption)));
            }
        }
 public SubInterface(Fleet fleet, CRM crm) : base(fleet, crm)
 {
 }