class Bicycle {
int cadence = 0;
int speed = 0;
int gear = 1;
int price = 0;
String name; // added string name for the name of bike there are two different...
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void bickeprice(int newValue){
price = newValue;
}
void printStates() {
System.out.println("bike:" + name
"Cadence: " +
cadence + " speed:" +
speed + " gear:" + gear + " it costs:" + price);
}
int availability() { //made these for choose option
System.out.print("there are only two bikes at that moment:");
System.out.println("which one would you like to see?");
System.out.println ("Continue? (1/2): ");
char choice = scan.next().charAt(0);//scan for the char
if(choice == '1'){
bike1.printStates(); //starts the menu again if char == y
}
if (choice == '2'){
bike1.printStates();
}
else {
System.exit(0); //else exits
}
}
class BicycleDemo {
public static void main(String[] args) {
// Create two different
// Bicycle objects
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();
// Invoke methods on
// those objects
bike1.name(giant); // these is the name for bike 1 but getting errors,
bike1.changeCadence(50);
bike1.speedUp(10);
bike1.changeGear(2);
bike1.printStates();
bike1.bickeprice(100);
bike2.changeCadence(50);
bike2.name(xxx);
bike2.speedUp(10);
bike2.changeGear(2);
bike2.changeCadence(40);
bike2.speedUp(10);
bike2.changeGear(3);
bike2.bickeprice(150);
bike2.printStates();
}
}