[solved]-Assignment Modify Existing Code Create Single Java Program Named Bicycledemojava Incorpora Q39072693
For this assignment, you will modify existing code to create asingle Java™ program named BicycleDemo.java that incorporates thefollowing:
An abstract Bicycle class that contains private data relevant toall types of bicycles (cadence, speed, and gear) in addition to onenew static variable: bicycleCount. The private data must be madevisible via public getter and setter methods; the static variablemust be set/manipulated in the Bicycle constructor and made visiblevia a public getter method.
Two concrete classes named MountainBike and RoadBike, both ofwhich derive from the abstract Bicycle class and both of which addtheir own class-specific data and getter/setter methods.
Adapt the Bicycle class by cutting and pasting the class intothe NetBeans editor and completing the following: Change theBicycle class to be an abstract class.
Add a private variable of type integer named bicycleCount, andinitialize this variable to 0.
Change the Bicycle constructor to add 1 to the bicycleCount eachtime a new object of type Bicycle is created.
Add a public getter method to return the current value ofbicycleCount.
Derive two classes from Bicycle: MountainBike and RoadBike. Tothe MountainBike class, add the private variables tireTread(String) and mountainRating (int). To the RoadBike class, add theprivate variable maximumMPH (int).
Using the NetBeans editor, adapt the BicycleDemo class asfollows:
Create two instances each of MountainBike and RoadBike. Displaythe value of bicycleCount on the console. Comment each line of codeyou add to explain what you added and why. Be sure to include aheader comment that includes the name of the program, your name,PRG/421, and the date. Rename your JAVA file to have a .txt fileextension.
Here is the code to adapt:
package bicycledemo;
class Bicycle { int cadence = 0; int speed = 0; int gear =1;
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 printStates() { System.out.println(“cadence:” + cadence + “speed:” + speed + ” gear:” + gear); } }
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.changeCadence(50); bike1.speedUp(10); bike1.changeGear(2);bike1.printStates();
bike2.changeCadence(50); bike2.speedUp(10); bike2.changeGear(2);bike2.changeCadence(40); bike2.speedUp(10); bike2.changeGear(3);bike2.printStates(); } }
Expert Answer
Answer to For this assignment, you will modify existing code to create a single Java™ program named BicycleDemo.java that incorp… . . .
OR

