Learn

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.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?