Beispiel #1
0
        private void SeedGas()
        {
            GasCar f150     = new GasCar("Ford F-150", 16);
            GasCar fiestaST = new GasCar("Ford Fiesta ST", 25);

            _repoGas.AddGasCarToDirectory(f150);
            _repoGas.AddGasCarToDirectory(fiestaST);
        }
        //CRUD - Create, Read, Update, Delete
        public bool AddGasCarToDirectory(GasCar item)
        {
            int startingCount = _gasDirectory.Count;

            _gasDirectory.Add(item);
            bool wasAdded = _gasDirectory.Count == startingCount + 1;

            return(wasAdded);
        }
        public bool RemoveGasByName(string name)
        {
            GasCar item = GetGasByName(name);

            if (item == null)
            {
                Console.WriteLine("This is not the car you want");
                return(false);
            }
            else
            {
                _gasDirectory.Remove(item);
                return(true);
            }
        }
        public bool UpdateGasByName(string name, GasCar newCar)
        {
            GasCar item = GetGasByName(name);

            if (item == null)
            {
                return(false);
            }
            else
            {
                item.Name       = newCar.Name;
                item.GasMileage = newCar.GasMileage;
                return(true);
            }
        }
Beispiel #5
0
        //-----Option 4 on prompt----------------------------

        public void UpdateCar()
        {
            Console.Write("What Car Do You Want To Update?\n" +
                          "1.Gas Car\n" +
                          "2.Hybrid Car\n" +
                          "3.Electric Car\n" +
                          "4.World Saving Green Car");
            string car = Console.ReadLine();

            switch (car)
            {
            case "1":
                //gas
                Console.WriteLine("What Car Do You Want To Update: ");
                string gas = Console.ReadLine();
                Console.WriteLine("What Is The New Fuel Economy: ");
                int    fuel   = Convert.ToInt32(Console.ReadLine());
                GasCar newCar = new GasCar(gas, fuel);
                _repoGas.UpdateGasByName(gas, newCar);
                Console.ReadKey();
                break;

            case "2":
                //hybrid
                Console.WriteLine("What Car Do You Want To Update: ");
                string hybrid = Console.ReadLine();
                Console.WriteLine("What Is The New Fuel Economy: ");
                int       fuel1   = Convert.ToInt32(Console.ReadLine());
                HybridCar newCar1 = new HybridCar(hybrid, fuel1);
                _repoHybrid.UpdateHybridByName(hybrid, newCar1);
                Console.ReadKey();
                break;

            case "3":
                //electric
                Console.WriteLine("What Car Do You Want To Update: ");
                string electric = Console.ReadLine();
                Console.WriteLine("What Is The New Fuel Economy: ");
                int         fuel2   = Convert.ToInt32(Console.ReadLine());
                ElectricCar newCar2 = new ElectricCar(electric, fuel2);
                _repoElectric.UpdateElectricByName(electric, newCar2);
                Console.ReadKey();
                break;

            case "4":
                //green
                Console.WriteLine("What Car Do You Want To Update: ");
                string green = Console.ReadLine();
                Console.Write("What Is The New Fuel Economy: ");
                int fuel3 = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Green? I Shure Hope So, So Which Is It? (Green, LimeGreen, DarkGreen, BrightGreen, NeonGreen, ArmyGreen) ");
                string color = Console.ReadLine();
                if (color == "Green")
                {
                    RealGreenCar newCar3 = new RealGreenCar(green, fuel3, Color.Green);
                    _repoRealGreen.UpdateRealGreenByName(green, newCar3);
                }
                else if (color == "LimeGreen")
                {
                    RealGreenCar newCar3 = new RealGreenCar(green, fuel3, Color.LimeGreen);
                    _repoRealGreen.UpdateRealGreenByName(green, newCar3);
                }
                else if (color == "DarkGreen")
                {
                    RealGreenCar newCar3 = new RealGreenCar(green, fuel3, Color.DarkGreen);
                    _repoRealGreen.UpdateRealGreenByName(green, newCar3);
                }
                else if (color == "BrightGreen")
                {
                    RealGreenCar newCar3 = new RealGreenCar(green, fuel3, Color.BrightGreen);
                    _repoRealGreen.UpdateRealGreenByName(green, newCar3);
                }
                else if (color == "NeonGreen")
                {
                    RealGreenCar newCar3 = new RealGreenCar(green, fuel3, Color.NeonGreen);
                    _repoRealGreen.UpdateRealGreenByName(green, newCar3);
                }
                else if (color == "ArmyGreen")
                {
                    RealGreenCar newCar3 = new RealGreenCar(green, fuel3, Color.ArmyGreen);
                    _repoRealGreen.UpdateRealGreenByName(green, newCar3);
                }
                Console.ReadKey();
                break;

            default:
                Console.WriteLine("Incorrect Entry");
                Console.ReadKey();
                break;
            }
            Console.WriteLine("Car Has Been Updated!");
            Console.ReadKey();
            RunMenu();
        }
Beispiel #6
0
        //-----Option 2 on prompt------------------------------
        public void AddCar()
        {
            Console.Clear();

            string aDescription = Console.ReadLine();

            Console.Write("Enter Car Name (Make + Model): ");
            string aCarName = Console.ReadLine();

            Console.Write("How Many Miles Will It Drive On 1 Gallon Of Gasoline? ");
            int aGasMileage = Convert.ToInt32(Console.ReadLine());

            Console.Write("What Type Of Car Is This?\n" +
                          "1. Gasoline Powered!\n" +
                          "2. Hybrid Boring?\n" +
                          "3. Electric Interesting?\n" +
                          "4. True Green Cars That Save The World!");
            string selection = Console.ReadLine();

            switch (selection)
            {
            case "1":
                //gas
                GasCar newGas = new GasCar(aCarName, aGasMileage);
                _repoGas.AddGasCarToDirectory(newGas);
                Console.ReadKey();
                break;

            case "2":
                //hybrid
                HybridCar newHybrid = new HybridCar(aCarName, aGasMileage);
                _repoHybrid.AddHybridCarToDirectory(newHybrid);
                Console.ReadKey();
                break;

            case "3":
                //electric
                ElectricCar newElectric = new ElectricCar(aCarName, aGasMileage);
                _repoElectric.AddElectricCarToDirectory(newElectric);
                Console.ReadKey();
                break;

            case "4":
                //green
                Console.Write("What Beautiful Shade Of Green? (Green, LimeGreen, DarkGreen, BrightGreen, NeonGreen, ArmyGreen) ");
                string color = Console.ReadLine();
                if (color == "Green")
                {
                    RealGreenCar newRealGreen = new RealGreenCar(aCarName, aGasMileage, Color.Green);
                    _repoRealGreen.AddRealGreenCarToDirectory(newRealGreen);
                }
                else if (color == "LimeGreen")
                {
                    RealGreenCar newRealGreen = new RealGreenCar(aCarName, aGasMileage, Color.LimeGreen);
                    _repoRealGreen.AddRealGreenCarToDirectory(newRealGreen);
                }
                else if (color == "DarkGreen")
                {
                    RealGreenCar newRealGreen = new RealGreenCar(aCarName, aGasMileage, Color.DarkGreen);
                    _repoRealGreen.AddRealGreenCarToDirectory(newRealGreen);
                }
                else if (color == "BrightGreen")
                {
                    RealGreenCar newRealGreen = new RealGreenCar(aCarName, aGasMileage, Color.BrightGreen);
                    _repoRealGreen.AddRealGreenCarToDirectory(newRealGreen);
                }
                else if (color == "NeonGreen")
                {
                    RealGreenCar newRealGreen = new RealGreenCar(aCarName, aGasMileage, Color.NeonGreen);
                    _repoRealGreen.AddRealGreenCarToDirectory(newRealGreen);
                }
                else if (color == "ArmyGreen")
                {
                    RealGreenCar newRealGreen = new RealGreenCar(aCarName, aGasMileage, Color.ArmyGreen);
                    _repoRealGreen.AddRealGreenCarToDirectory(newRealGreen);
                }
                Console.ReadKey();
                break;

            default:
                Console.WriteLine("Incorrect Entry");
                Console.ReadKey();
                break;
            }
            Console.WriteLine("New car added!");
            Console.ReadLine();
            RunMenu();
        }
Beispiel #7
0
 public void DisplayContent(GasCar item)
 {
     Console.WriteLine($"{item.Name,-20} {item.GasMileage,-30}\n");
 }