Example #1
0
        static void Main(string[] args)
        {
            //create different cars and "drive" them
            ICar explorer = new GasCar("Ford", "Explorer", 20, 15);
            ICar leaf     = new ElectricCar("Nissan", "Leaf", 60, 3);
            ICar pinto    = new GasCar("Ford", "Pinto", 10, 20);

            List <ICar> cars = new List <ICar>()
            {
                explorer,
                leaf,
                pinto
            };

            //sort list by MPG
            cars.Sort(new MilesPerGallonComparer());
            cars.Reverse();

            foreach (ICar car in cars)
            {
                car.Start();
                Console.WriteLine("MPG " + car.GetMilesPerGallon());
                car.Drive(75);
                car.Drive(50);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            //TODO: create different cars and "drive" them
            GasCar explorer = new GasCar("Ford", "Explorer", 20, 15);

            explorer.Drive(75);
            explorer.Drive(50);

            ElectricCar leaf = new ElectricCar("Nissan", "Leaf", 60, 3);

            leaf.Drive(200);
            leaf.Drive(15);
        }
Example #3
0
        static void Main(string[] args)
        {
            //TODO: create different cars and drive them
            //Car car = new Car("Ford", "Prefect");
            GasCar      explorer = new GasCar("Ford", "Explorer", 20, 15);
            ElectricCar leaf     = new ElectricCar("Nissan", "Leaf", 75, 3);

            //Console.WriteLine(explorer.Make);
            //Console.ReadKey();

            explorer.Drive(75);
            explorer.Drive(50);
            leaf.Drive(200);
            leaf.Drive(200);
        }