使用构造函数创建Bicycle类
public class Bicycle { // the Bicycle class has three fields /** 时 代 J a v a - nowjava.com 提供 **/ public int cadence; public int gear; public int speed; public Bicycle() { super(); } public Bicycle(int startCadence, int startSpeed, int startGear) { gear = startGear; cadence = startCadence; speed = startSpeed; } /** 来 自 n o w j a v a . c o m - 时 代 Java **/ public void setCadence(int newValue) { cadence = newValue; } public void setGear(int newValue) { gear = newValue; } public void applyBrake(int decrement) { speed -= decrement; } public void speedUp(int increment) { speed += increment; } public void printDescription() { System.out.println("\nBike is in gear " + this.gear + " with a cadence of " + this.cadence + " and travelling at a speed of " + this.speed + ". "); } }