Esempio n. 1
0
        static void Main(string[] args)
        {
            Car myCar = new Car();

            myCar.honk();

            Console.WriteLine(myCar.brand + "  " + myCar.modelName);
        }
        static void Main(string[] args)
        {
            Car myCar = new Car();

            // Call the honk() method (From the Vehicle class) on the myCar object
            myCar.honk();

            // Display the value of the brand field (from the Vehicle class) and the value of the modelName from the Car class
            Console.WriteLine(myCar.brand + " " + myCar.modelName);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Bmw myBimmer = new Bmw("BMW", 340, 2005);

            Console.WriteLine(myBimmer.year + " " + myBimmer.brand + " " + myBimmer.model + "(" + myBimmer.hp + "hp)");

            Car myCar  = new Car();
            Car myBmw  = new Bmw("bmw", 230, 2020);
            Car myBenz = new Benz();

            myCar.honk();   //virtual
            myBmw.honk();   //override
            myBenz.honk();  //virtual
        }