/ Published in: Java
This lab #2 from my Programming with Java class
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public class Bicycle { private int cadence; private int gear; private int speed; public Bicycle(int startCadence, int startGear, int startSpeed) { cadence = startCadence; gear = startGear; speed = startSpeed; } public int getCadence() { return cadence; } public void setCadence(int cadence) { this.cadence = cadence; } public int getGear() { return gear; } public void setGear(int gear) { this.gear = gear; } public int getSpeed() { return speed; } public void setSpeed(int speed) { this.speed = speed; } public void ApplyBrake(int decrement) { speed -= decrement; } public void speedUp(int increment) { speed += increment; } public void PrintValues() { } { Bicycle myBike = new Bicycle(30,0,1); myBike.PrintValues(); myBike.speedUp(30); myBike.setGear(2); myBike.PrintValues(); } }