Exemple #1
0
        private void SeedRealGreen()
        {
            RealGreenCar gt3rs  = new RealGreenCar("Porsche GT3 RS", 19, Color.NeonGreen);
            RealGreenCar hummer = new RealGreenCar("AMC Hummer H1", 10, Color.DarkGreen);

            _repoRealGreen.AddRealGreenCarToDirectory(gt3rs);
            _repoRealGreen.AddRealGreenCarToDirectory(hummer);
        }
        //CRUD - Create, Read, Update, Delete
        public bool AddRealGreenCarToDirectory(RealGreenCar item)
        {
            int startingCount = _realGreenDirectory.Count;

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

            return(wasAdded);
        }
        public bool RemoveRealGreenByName(string name)
        {
            RealGreenCar item = GetRealGreenByName(name);

            if (item == null)
            {
                Console.WriteLine("This is not the car you want");
                return(false);
            }
            else
            {
                _realGreenDirectory.Remove(item);
                return(true);
            }
        }
        public bool UpdateRealGreenByName(string name, RealGreenCar newCar)
        {
            RealGreenCar item = GetRealGreenByName(name);

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