// Main Method public static void Main(String[] args) { // creating an instance of Bicycle Bicycle bicycle = new Bicycle(); // Creating interface references Vehicle obj; // assigning Bicycle object 'bicycle' // to interface Reference 'obj' obj = bicycle; // calling the abstract methods // implemented by class Bicycle obj.changeGear(4); obj.speedUp(5); obj.applyBrakes(2); Console.WriteLine("Bicycle Present State:"); // calling the method of class Bicycle obj.printStates(); }
public static void Main(String[] args) { // Instantiate the an object 'bicycle' using // the default constructor for the Bicycle class // The parameters for each method inside the class // are passed using literals Bicycle bicycle = new Bicycle(); bicycle.ChangeGear(2); bicycle.SpeedUp(3); bicycle.ApplyBrakes(1); Console.WriteLine("Bicycle present state :"); bicycle.printStates(); Scooter scooter = new Scooter(); scooter.ChangeGear(1); scooter.SpeedUp(4); scooter.ApplyBrakes(3); Console.WriteLine("Scooter present state :"); scooter.printStates(); }