static void Main(string[] args)
    {
        VolvoC30 myCar = new VolvoC30("Adam Freeman", PaintColor.Black);

        PaintColor color = PaintColor.Green;

        switch (color)
        {
        case PaintColor.Black:
            Console.WriteLine("Paint Color is black");
            break;

        case PaintColor.Green:
            Console.WriteLine("Paint Color is green");
            break;

        case PaintColor.Red:
        case PaintColor.Silver:
            Console.WriteLine("Paint Color is red or silver");
            break;
        }

        if (color == PaintColor.Black)
        {
            Console.WriteLine("Paint color is black");
        }


        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
    public static void Main()
    {
        // create an EngineSpec object
        EngineSpec spec = new EngineSpec(2000, "Diesel");

        // create a new object of the VolvoC30 type
        VolvoC30 myCar = new VolvoC30("Adam Freeman", "Black", spec);

        // create a second VolvoC30 object
        VolvoC30 joesCar = new VolvoC30("Joe Smith", "Silver", spec);

        // read and print out the Engine.EngineCapacity field of both objects
        // and the local variable
        Console.WriteLine("--- Values Before Change ---");
        Console.WriteLine("Local EngineSpec Variable: {0}", spec.EngineCapacity);
        Console.WriteLine("myCar field value: {0}", myCar.Engine.EngineCapacity);
        Console.WriteLine("joesCar field value: {0}", joesCar.Engine.EngineCapacity);

        // modify the capacity of the local variable
        spec.EngineCapacity = 2500;

        // read and print out the Engine.EngineCapacity field of both objects
        // and the local variable
        Console.WriteLine("--- Values After Change ---");
        Console.WriteLine("Local EngineSpec Variable: {0}", spec.EngineCapacity);
        Console.WriteLine("myCar field value: {0}", myCar.Engine.EngineCapacity);
        Console.WriteLine("joesCar field value: {0}", joesCar.Engine.EngineCapacity);

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
    static void Main(string[] args)
    {
        // create a new instance of Car
        //Car myCar = new Car("Adam Freeman", "Black", 30);
        //myCar.PrintCarDetails();

        // create an instance of VolvoCar
        //VolvoCar myVolvo = new VolvoCar("Adam Freeman", "Black", 30, "High Performance");
        //myVolvo.PrintCarDetails();

        //int fuelRequired = myVolvo.CalculateFuelForTrip(1000);
        //Console.WriteLine("Fuel Required: {0} gallons", fuelRequired);

        VolvoC30 myC30 = new VolvoC30("Adam Freeman", "Black", 30, "High Performance");

        myC30.PrintCarDetails();
        FordFiesta myFiesta = new FordFiesta("Joe Smith", "Yellow", 35, "18 inch sports");

        myFiesta.PrintCarDetails();



        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
Example #4
0
    public static void Main()
    {
        // create a new object of the MyClass type
        VolvoC30 myCar = new VolvoC30();

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
Example #5
0
    static void Main(string[] args)
    {
        VolvoC30 myCar = new VolvoC30("Black");

        Console.WriteLine("Car: {0}", myCar);

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
Example #6
0
    public static void Main()
    {
        // create a new object of the VolvoC30 type
        VolvoC30 myCar = new VolvoC30("Adam Freeman", "Black");

        // create a second VolvoC30 object
        VolvoC30 joesCar = new VolvoC30("Joe Smith", "Silver");

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
    static void Main(string[] args)
    {
        // create a VolvoC30 object
        VolvoC30 myVolvo = new VolvoC30("Adam Freeman", "Black");

        // create a FordFiesta object
        FordFiesta myFord = new FordFiesta("Joe Smith", "Green");

        // call the PrintCarDetails method on both car objects
        myVolvo.PrintCarDetails();
        myFord.PrintCarDetails();

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
    public static void Main()
    {
        // create a new VolvoC30 object
        VolvoC30 myCar = new VolvoC30("Adam Freeman", "Black");

        // call the CalculateFuelForTrip for a 1000 mile trip
        int fuelRequired = myCar.CalculateFuelForTrip(1000);

        Console.WriteLine("Fuel Required: {0} gallons", fuelRequired);

        // call the PrintCarDetails method
        myCar.PrintCarDetails();

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
Example #9
0
    public static void Main()
    {
        // create a new object of the VolvoC30 type
        VolvoC30 myCar = new VolvoC30("Adam Freeman", "Black");

        // create a second VolvoC30 object
        VolvoC30 joesCar = new VolvoC30("Joe Smith", "Silver");

        // read the value of the myCar.CarOwner field
        string owner = myCar.CarOwner;

        Console.WriteLine("Field value: {0}", owner);

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
Example #10
0
    static void Main(string[] args)
    {
        // create a GenericStack<T> using the derived type
        GenericStack <VolvoC30> volvoStack = new GenericStack <VolvoC30>();

        //// upcast the paramterized type
        //GenericStack<Car> carStack = volvoStack;    // this won't compile

        //// push in a data item via the upcast instance
        //carStack.Push(new FordFiesta());

        // pop the contents via the original instance
        // CAUTION - this would cause an exception because
        // although we are expecting a VolvoC30 object, we
        // are actually going to get a FordFiesta instead
        VolvoC30 dataItem = volvoStack.Pop();

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
Example #11
0
    public static void Main()
    {
        // define a common service interval variable
        int serviceInterval = 40000;

        // create a new object of the VolvoC30 type
        VolvoC30 myCar = new VolvoC30("Adam Freeman", "Black", serviceInterval);

        // create a second VolvoC30 object
        VolvoC30 joesCar = new VolvoC30("Joe Smith", "Silver", serviceInterval);

        // modify the value of service interval in myCar
        myCar.ServiceInterval = 50000;

        // read and print out the ServiceInterval field for both objects
        Console.WriteLine("myCar field value: {0}", myCar.ServiceInterval);
        Console.WriteLine("joesCar field value: {0}", joesCar.ServiceInterval);

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }