コード例 #1
0
    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();
    }
コード例 #2
0
    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();
    }
コード例 #3
0
    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();
    }