Help with C# Overriding Base Class Members

  • Thread starter Thread starter jeskit
  • Start date Start date
J

jeskit

Guest
I am currently working through the SAMS Tecah yourself Visual C# 2010 in 24 hours book and i am stuck on the Overriding Base Class Members exercise:

namespace Class_Inheritance_and_Polymorphism
{
class Program
{
static void Main(string[] args)
{
Car c = new Car();
Motorcycle m = new Motorcycle();
Truck t = new Truck();
Tryke tr = new Tryke();
Vehicle v1 = c;
Vehicle v3 = m;
Vehicle v2 = t;
Vehicle v4 = tr;

}
}

public class Vehicle
{
private Vehicle() { }
public Vehicle(int wheels)
{
Console.WriteLine("The number of wheels requested is {0}", wheels);
}
}

public class FourWheeledVehicle : Vehicle
{
public FourWheeledVehicle() : base(4) { }
}

public class TwoWheeledVehicle : Vehicle
{
public TwoWheeledVehicle() : base(2) { }
}

public class ThreeWheeledVehicle : Vehicle
{
public ThreeWheeledVehicle() : base(3) { }
}

public class Car : FourWheeledVehicle { }

public class Truck : FourWheeledVehicle { }

public class Motorcycle : TwoWheeledVehicle { }

public class Tryke : ThreeWheeledVehicle { }
}


However for this exercise it says:

1544228.jpg

I am a little stuck on this i am unsure of what i need to change/add. The chapter for this exercise was not very informative. Could anyone help me please?

Continue reading...
 
Back
Top