Esempio n. 1
0
        private void SeedElectric()
        {
            ElectricCar modelX = new ElectricCar("Tesla Model X", 1000);
            ElectricCar modelS = new ElectricCar("Tesla Model Y", 1000);

            _repoElectric.AddElectricCarToDirectory(modelX);
            _repoElectric.AddElectricCarToDirectory(modelS);
        }
Esempio n. 2
0
        //CRUD - Create, Read, Update, Delete
        public bool AddElectricCarToDirectory(ElectricCar item)
        {
            int startingCount = _electricDirectory.Count;

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

            return(wasAdded);
        }
Esempio n. 3
0
        public bool RemoveElectricByName(string name)
        {
            ElectricCar item = GetElectricByName(name);

            if (item == null)
            {
                Console.WriteLine("This is not the car you want");
                return(false);
            }
            else
            {
                _electricDirectory.Remove(item);
                return(true);
            }
        }
Esempio n. 4
0
        public bool UpdateElectricByName(string name, ElectricCar newCar)
        {
            ElectricCar item = GetElectricByName(name);

            if (item == null)
            {
                return(false);
            }
            else
            {
                item.Name       = newCar.Name;
                item.GasMileage = newCar.GasMileage;
                return(true);
            }
        }
Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 7
0
 public void DisplayContent(ElectricCar item)
 {
     Console.WriteLine($"{item.Name,-20} {item.GasMileage,-30}\n");
 }