Exercise 2

1 Create Subclasses and Superclasses

In this exercise you should create a partial class Vehicle with the variable speed. You should also create four classes; Car, Boat, Train and Bicycle which inherit from Vehicle. Remember the variables for each subclass, which you can see in the picture below:

The Vehicle class and different classes inheriting from Vehicle.

Vehicle class:

Car class:

Boat class:

Train class:

Bicycle class:

Let's write an instance of Train!


1.1.1 Vehicle

1.1.2 Car, Boat, Train and Bicycle

1.1.3 Instance of Train