Skip to Content
Learn
Interfaces
Testing Interfaces

Now we have a Sedan class and Truck class that implement the IAutomobile interface. Though they have some different behaviors, they both have the properties and method defined in the interface:

  • double Speed
  • string LicensePlate
  • int Wheels
  • void Honk()

At this point we can be confident that we won’t cause any errors if we try to access these members in either the Sedan or Truck class.

Instructions

1.

Create two sedans and a truck:

  • a sedan with speed 60
  • a sedan with speed 70
  • a truck with speed 45 and weight 500
2.

Write three Console.WriteLine() statements that print the automobiles’ Speed, Wheels, and LicensePlate.

3.

Call SpeedUp() on all three automobiles.

4.

Using Console.WriteLine(), print out the three automobile’s new speeds.

Folder Icon

Take this course for free

Already have an account?