Question: Q 1 g ) ( 1 0 pts ) Create the following class Bicycle class Bicycle extends Vehicle implements Comparable weight: double Bicycle ( )

Q1 g )(10 pts ) Create the following class Bicycle
class Bicycle extends Vehicle implements Comparable
weight: double
Bicycle()//SEE NOTE 1
Bicycle(Person driver)//SEE NOTE 2
Bicycle(Person driver, double weight)//SEE NOTE 3
equals(Object o): boolean //same weight. ACCURACY_RANGE =0.5//SEE NOTE 4
getWeight(): double
setWeight(double w): void
setDriver(Person p): void throws InvalidDriverException //SEE NOTE 5
toString(): String //"Bicycle [ rider="+ getDriver().getName()+"| weight="+ weight +"]"
compareTo(Bicycle b)//ACCURACY_RANGE =0.5//SEE NOTE 6
Notes for Bicycle class:
This constructor calls the parent classs constructor, passing in 1 for the numRows and 1 for the numSeatsPerRow before initializing weight to 0.
This constructor calls the parent classs constructor, passing in the specified driver and an array specifying that there is only one row with one seat,before initializing weight to 0.
This constructor calls the parent classs constructor, passing in the specified driver and an array specifying that there is only one row with one seat, before setting the weight. (Negative weight not permitted, set to 0 if that occurs).
Two bicycle objects are considered equal if their weights are within 0.5 of each other regardless of who the driver is.
Override the inherited setDriver method so that any Person age 3 or older can be the driver of the Bicycle. If the driver is younger than 3, throw an InvalidDriverException
If the calling objects weight is less than the passed in objects weight by more than the ACCURACY_RANGE return -1. If the calling objeQ1 g )(10 pts ) Create the following class Bicycle
class Bicycle extends Vehicle implements Comparable
weight: double
Bicycle()//SEE NOTE 1
Bicycle(Person driver)//SEE NOTE 2
Bicycle(Person driver, double weight)//SEE NOTE 3
equals(Object o): boolean //same weight. ACCURACY_RANGE =0.5//SEE NOTE 4
getWeight(): double
setWeight(double w): void
setDriver(Person p): void throws InvalidDriverException //SEE NOTE 5
toString(): String //"Bicycle [ rider="+ getDriver().getName()+"| weight="+ weight +"]"
compareTo(Bicycle b)//ACCURACY_RANGE =0.5//SEE NOTE 6
Notes for Bicycle class:
This constructor calls the parent classs constructor, passing in 1 for the numRows and 1 for the numSeatsPerRow before initializing weight to 0.
This constructor calls the parent classs constructor, passing in the specified driver and an array specifying that there is only one row with one seat,before initializing weight to 0.
This constructor calls the parent classs constructor, passing in the specified driver and an array specifying that there is only one row with one seat, before setting the weight. (Negative weight not permitted, set to 0 if that occurs).
Two bicycle objects are considered equal if their weights are within 0.5 of each other regardless of who the driver is.
Override the inherited setDriver method so that any Person age 3 or older can be the driver of the Bicycle. If the driver is younger than 3, throw an InvalidDriverException
If the calling objects weight is less than the passed in objects weight by more than the ACCURACY_RANGE return -1. If the calling objects weight is greater than the passed in objects weight by more than the ACCURACY_RANGE return 1. Otherwise return 0;
Be sure to implement the loadPassenger, and loadPassengers methods in the Bicycle class. Hint: A Bicycle cannot have any passengers. (A driver is not a passenger)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!