Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Bicycle
- {
- // member variables
- int pedalRate;
- int speed;
- int gear;
- // constructor for class without parameters
- public Bicycle()
- {
- this.pedalRate = 1;
- this.speed = 10;
- this.gear = 0;
- }
- // constructor for class with parameters
- public Bicycle(int pR, int sP, int g)
- {
- this.pedalRate = pR;
- this.speed = sP;
- this.gear = g;
- }
- public void changePedalRate(int newValue)
- {
- pedalRate = newValue;
- }
- public void changeGear(int newValue)
- {
- gear = newValue;
- }
- public void speedUp(int increment)
- {
- speed += increment;
- }
- public void applyBrakes(int decrement)
- {
- speed -= decrement;
- }
- public void printStates()
- {
- System.out.println("pedalRate: " + pedalRate + "\nspeed: " + speed
- + "\ngear: " + gear);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment