Define an interface as follows: Interface Bicycle { // wheel revolutions per minute void changeCadence(int newValue); //will change value of candence to new value void changeGear (int newValue);...


Define an interface as follows:


Interface Bicycle {



    // wheel revolutions per minute


void changeCadence(int newValue); //will change value of candence to new value



void changeGear (int newValue); changes gear of car


void speedUp(int increment); //increments speed of car by adding new Value to existing speed


 void applyBrakes(int decrement); }//decease car speed by subtracting value from speed.



To implement this interface, the name of your class would change (to a particular brand of bicycle, for example, such as ACMEBicycle, KEYOBicycle), and you'd use the implements keyword in the class declaration:


class ACMEBicycle implements Bicycle{


int cadence = 0;


 int speed = 0;


 int gear = 1;


//methods of interface


}


These clases will implements the abstract method of interface and provide definitions according to them. Now in main class you will ask user what kind of bicycle he/she wants create object of that class, then asks user for options


1. Change cadence


2. Change gear


3. Speed UP


4. Apply brakes


Call appropriate method and print values at the end.


Programming language : Java



Jun 01, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here