Example #1
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car DONE


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car
            Carlot lot = new Carlot();

            //Using Dot Notation
            Car fiat = new Car();

            lot.CarList.Add(fiat);
            fiat.CarMake     = "Fiat";
            fiat.CarModel    = "500 Abarth";
            fiat.CarYear     = 2015;
            fiat.EngineNoise = "Vroom";
            fiat.Horn        = "beep";
            fiat.IsDrivable  = true;

            //Object Initializer Syntax
            Car grandPrix = new Car()
            {
                CarYear     = 2006,
                CarMake     = "Pontiac",
                CarModel    = "Grand Prix",
                EngineNoise = "Nyoom",
                Horn        = "meepmeep",
                IsDrivable  = false
            };

            lot.CarList.Add(grandPrix);
            //Using the Constructor to allow parameter values to be placed inside properties.
            Car jeep = new Car(2018, "Jeep", "Cherokee", "vroom", "honkhonk", true);

            lot.CarList.Add(jeep);
            //Call Methods.
            fiat.MakeEngineNoise(fiat.EngineNoise);
            grandPrix.MakeEngineNoise(grandPrix.EngineNoise);
            jeep.MakeEngineNoise(jeep.EngineNoise);

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            foreach (var car in lot.CarList)
            {
                Console.WriteLine();
                Console.WriteLine($"Year: {car.CarYear} Make: {car.CarMake} and Model: {car.CarModel}");
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            var lot = new Carlot();

            Car mustang = new Car()
            {
                Year = 2004, Make = "Ford", Model = "Mustang"
            };

            mustang.MakeEngineNoise();
            mustang.MakeHonkNoise();

            lot.CarList.Add(mustang);
Example #3
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property
            Carlot listofcar = new Carlot();
            Car    firstcar  = new Car(1992, "Ford", "Mustang", "available");

            //Car secondcar = new Car();

            //firstcar.Year = 1992;
            //firstcar.Model = "Ford";
            //firstcar.Make = "human";
            //firstcar.Isdliverable = "available";
            listofcar.AuthorList.Add(firstcar);
            //listofcar.display();
            Console.WriteLine($"{firstcar.Model} was made in {firstcar.Year} by {firstcar.Make} and it is now {firstcar.Isdeliverable}");
            //Console.WriteLine(firstcar.Model);
            Car secondcar = new Car(1992, "Ferrari", "Mustang", "available");

            listofcar.AuthorList.Add(secondcar);
            secondcar.speak();
            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car
            Car thirdcar = new Car(1992, "Ford", "Mustang", "available");

            thirdcar.speak();
            thirdcar.EngineNoise("Loud");
            thirdcar.honkNoise("Medium");
            listofcar.display();

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Example #4
0
        static void Main(string[] args)
        {
            //Done

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property

            //Done

            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars

            //Done

            //Call each of the methods for each car

            //
            //Instanciate the Carlot at the beginning of the program
            //and as you create a car add the car to the list.
            var myLot = new Carlot();

            //First way to created a new instance,
            //using . notation
            //now can access the properties of the
            //Car class to work with the new instance
            var carA = new Car();

            carA.Year        = 1967;
            carA.Make        = "Ford";
            carA.Model       = "Mustang";
            carA.EngineNoise = "vroom";
            carA.HonkNoise   = "beep";
            carA.IsDriveable = true;
            // Adding carA to local variable myLot we created for list of Cars
            // in the Carlot class
            // references travel from bigger container to smaller unit
            myLot.Cars.Add(carA);
            //object initializer syntax
            // - has scope,
            // properties are separated by a comma
            var carB = new Car()
            {
                Year        = 2017,
                Make        = "Honda",
                Model       = "Civic",
                EngineNoise = "tut",
                HonkNoise   = "beep",
                IsDriveable = false,
            };

            //Adding carB
            myLot.Cars.Add(carB);
            //Construction Pass
            //will pass through the new constructor we made in Class.cs
            var carC = new Car(2020, "Tesla", "Whateveritscalled", "wrrrr", "beep", true);

            myLot.Cars.Add(carC);
            //Calling Methods
            //Instance Method
            //Parameters go through parenthesis, Methods go through methods,
            //Instances of a class go through instances of a class
            //The method has instructions to print to console
            carC.MakeEngineNoise();
            carB.MakeEngineNoise();
            carA.MakeEngineNoise();
            //Using a foreach loop is for when you want to apply some factor to each
            //item in a list, array, etc??
            //using the local variable car, i can write to console

            foreach (var car in myLot.Cars)
            {
                Console.WriteLine($"{car.Year} {car.Make} {car.Model}");
            }

            //Done
            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //Done
            //*************BONUS X 2*************//
            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Example #5
0
        static void Main(string[] args)
        {
            var Carlist = new Carlot();

            Car mustang = new Car()
            {
                Year = 2004, Make = "Ford", Model = "Mustang"
            };

            mustang.MakeEngineNoise("VROOOOM");
            mustang.MakeHonkNoise("Beep");
            var Inventory = new Carlot()
            {
                Carlist = (Car)mustang
            };



            Car Cherokee = new Car();

            Cherokee.Year  = 1974;
            Cherokee.Make  = "Jeep";
            Cherokee.Model = "Cherokee";
            Cherokee.MakeEngineNoise("Sputter");
            Cherokee.MakeHonkNoise("Meep");

            Carlist.Add(Cherokee);


            Car Corolla = new Car()
            {
                Year  = 2008,
                Make  = "Toyota",
                Model = "Corolla"
            };

            Corolla.MakeEngineNoise("whir");
            Corolla.MakeHonkNoise("Clown horn sound");

            Carlist.Add(Corolla);

            foreach (var x in Carlist)
            {
                Console.WriteLine(x);
            }

            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Example #6
0
        static void Main(string[] args)
        {
            //TODO

            //Create a seperate class file called Car
            //Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //The methods should take one string parameter: the respective noise property


            //Now that the Car class is created we can instanciate 3 new cars
            //Set the properties for each of the cars
            //Call each of the methods for each car

            //*************BONUS*************//

            // Set the properties utilizing the 3 different ways we learned about, one way for each car

            Carlot lot = new Carlot();


            Car bmw = new Car();

            lot.CarList.Add(bmw);
            bmw.Year        = 2003;
            bmw.Make        = "bmw";
            bmw.Model       = "328i";
            bmw.EngineNoise = "Waaw!";
            bmw.HonkNoise   = "Beeeep";
            bmw.IsDriveable = true;

            bmw.MakeEngineNoise();
            bmw.MakeHonkNoise();

            Car celica = new Car()
            {
                Year = 1999, Make = "Toyota", Model = "Celica", EngineNoise = "N/A", HonkNoise = "Whomp"
            };

            lot.CarList.Add(celica);


            celica.MakeEngineNoise();
            celica.MakeHonkNoise();

            Car Titan = new Car(2020, "Nissan", "Titan", "N/A", "Whaaaank");

            lot.CarList.Add(Titan);

            Titan.MakeEngineNoise();
            Titan.MakeHonkNoise();

            //*************BONUS X 2*************//

            foreach (var car in lot.CarList)
            {
                Console.WriteLine($"Year :{car.Year}, Make: {car.Make} Model: {car.Model}");
            }

            //Create a CarLot class
            //It should have at least one property: a List of cars
            //Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }
Example #7
0
        static void Main(string[] args)
        {
            //TODO
            var carlot = new Carlot();

            //DONE Create a seperate class file called Car
            //DONE Car shall have the following properties: Year, Make, Model, EngineNoise, HonkNoise, IsDriveable
            //DONE Car shall have the following methods: MakeEngineNoise(), MakeHonkNoise()
            //DONE The methods should take one string parameter: the respective noise property



            //DONE Now that the Car class is created we can instanciate 3 new cars
            //DONE Set the properties for each of the cars
            //DONE Call each of the methods for each car

            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");

            var myCar = new Car();

            myCar.Driver      = "Graybles";
            myCar.Make        = "Honda";
            myCar.Model       = "Accord";
            myCar.Year        = 2008;
            myCar.EngineNoise = "vroom vroom";
            myCar.HonkNoise   = "beep beep";
            myCar.IsDriveable = true;


            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");

            var stevosCar = new Car()
            {
                Driver      = "StevO!",
                Year        = 2020,
                Make        = "Tonka",
                Model       = "Super Truck",
                EngineNoise = "boom boom",
                HonkNoise   = "caw caw",
                IsDriveable = false
            };

            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");

            var jakesCar = new Car("Jake", 2001, "Ford", "Focus", "skrrrrrt", "boop boop", true);

            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");

            var jebsCar = new Car()
            {
                Driver      = "J3BBY M@N3",
                Year        = 3000,
                Make        = "Mars",
                Model       = "Rover Rumbler",
                EngineNoise = "bleep blorp",
                HonkNoise   = "Zing Zoooop!!",
                IsDriveable = true
            };

            Console.WriteLine($"Number of Cars created: {Carlot.numberOfCars}");


            myCar.MakeEngineNoise(myCar.EngineNoise);

            myCar.MakeHonkNoise(myCar.HonkNoise);

            jakesCar.MakeEngineNoise(jakesCar.EngineNoise);

            jakesCar.MakeHonkNoise(jakesCar.HonkNoise);

            stevosCar.MakeEngineNoise(stevosCar.EngineNoise);

            stevosCar.MakeHonkNoise(stevosCar.HonkNoise);

            jebsCar.MakeEngineNoise(jebsCar.EngineNoise);

            jebsCar.MakeHonkNoise(jebsCar.HonkNoise);



            //*************BONUS*************//

            //DONE Set the properties utilizing the 3 different ways we learned about, one way for each car

            //*************BONUS X 2*************//
            carlot.carList.Add(myCar);
            carlot.carList.Add(stevosCar);
            carlot.carList.Add(jakesCar);
            carlot.carList.Add(jebsCar);


            foreach (var Car in carlot.carList)
            {
                Console.WriteLine($"Driver: {Car.Driver} Year: {Car.Year} Make: {Car.Make} Model: {Car.Model}");
            }
            //DONE Create a CarLot class
            //DONE It should have at least one property: a List of cars
            //DONE Instanciate the a Carlot at the beginning of the program and as you create a car add the car to the list.
            //At the end iterate through the list printing each of car's Year, Make, and Model to the console
        }