/* ** Sample Class to demonstrate creating a 'bicycle' class ** ** (c) Copyright 2001 Simon Huggins */ public class Bicycle { // Create a new class available outside this file called Bicycle private int speed=0, gear=5; // Create variables only available within this class public double dynamoBrightness=0.0; /* Procedure to push down on the pedal - public, so can be used externally to the bike */ public int pushOnPedal() { speed++; // Increase the speed by 1 dynamoBrightness=speed/2.0; // Which has the effect of changing the dynamo brightness return speed; // and return the current speed as feedback } /* Procedure to push down on the brake handle - public again */ public int pushBrakeHandle() { speed--; // Decrease the speed by 1 dynamoBrightness=speed/2.0; // Which decreases the brightness of the dynamo return speed; // and return the current speed as feedback } public void setGear(int new_gear) { gear = new_gear; } /* Procedure to set the gear */ }