Revision: 23434
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 7, 2010 21:07 by rtipton
Initial Code
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() { System.out.println("Gear = " + gear); System.out.println("Cadence = " + cadence); System.out.println("Speed = " + speed); System.out.println(""); } public static void main(String [] args) { Bicycle myBike = new Bicycle(30,0,1); System.out.println("Bicycle Parameters"); System.out.println("==================="); myBike.PrintValues(); myBike.speedUp(30); myBike.setGear(2); System.out.println("New Bicycle Parameters"); System.out.println("======================="); myBike.PrintValues(); } }
Initial URL
Initial Description
This lab #2 from my Programming with Java class
Initial Title
Using Getters and Setters
Initial Tags
Initial Language
Java