Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Bicycle extends TwoWheeled { / / instance variable declarations private int gears = 0 ; private double cost = 0 . 0 ;

public class Bicycle extends TwoWheeled {
// instance variable declarations
private int gears =0;
private double cost =0.0;
private double weight =0.0;
private String color ="";
// constructor - default
public Bicycle(){
}
// constructor - String parameter
public Bicycle(String aColor){
this.color = aColor;
}
// constructor - int parameter
public Bicycle(int nbrOfGears){
this.gears = nbrOfGears;
}
// constructor - int, double, double, String parameters
public Bicycle(int nbrOfGears, double theCost, double theWeight, String aColor){
this.gears = nbrOfGears;
this.cost = theCost;
this.weight = theWeight;
this.color = aColor;
}
// method to output Bicycle's information
public void outputData(){
System.out.println("
Bicycle Details:");
System.out.println("Gears : "+ this.gears);
System.out.println("Cost : "+ this.cost);
System.out.println("Weight : "+ this.weight +" lbs");
System.out.println("Color : "+ this.color);
}
// method to output Bicycle's information - overloaded
//- method call chaining enabled
public Bicycle outputData(String bikeText){
System.out.println("
Bicycle "+ bikeText +" Details:");
System.out.println("Gears : "+ this.gears);
System.out.println("Cost : "+ this.cost);
System.out.println("Weight : "+ this.weight +" lbs");
System.out.println("Color : "+ this.color);
return this;
}
// Accessors (Getters)
public int getGears(){
return this.gears;
}
public double getCost(){
return this.cost;
}
public double getWeight(){
return this.weight;
}
public String getColor(){
return this.color;
}
// Mutators (Setters)- method call chaining enabled
public Bicycle setGears(int nbr){
this.gears = nbr;
return this;
}
public Bicycle setCost(double amt){
this.cost = amt;
return this;
}
public Bicycle setWeight(double lbs){
this.weight = lbs;
return this;
}
public Bicycle setColor(String theColor){
this.color = theColor;
return this;
}
}Create a UML diagram using this java code source

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

3. What are the current trends in computer hardware platforms?

Answered: 1 week ago