blog

C# programming

C# programming

Using the Bicycle class below, write a class called MountainBike that is a subclass of Bicycle with one int attribute called seatHeight. Include property for seatHeight, a default constructor and an overloaded constructor that takes all 4 values. Include a ToString() to display all 4 values.

public class Bicycle {

the Bicycle class has three fields protected int cadence; protected int gear; protected int speed;

public Bicycle() { }

public Bicycle(int startCadence, int startSpeed, int startGear) { gear = startGear; cadence = startCadence; speed = startSpeed; }

the Bicycle class has four methods public int Cadence { set { cadence = value; } get { return cadence; } }

public int Gear { set { gear = value; } get { return gear; } }

public int Speed { set { speed = value; } get { return speed; } }

public void applyBrake(int decrement) { speed -= decrement; }

public void speedUp(int increment) { speed += increment; }

public string ToString() { return “Cadence: “ + cadence + “ Gear: “ + gear + “ Speed: “ + speed; }

Is this the question you were looking for? If so, place your order here to get started!

×