Question: You will be implementing the Factory Design Pattern to create Bikes Your Bike Store will be your factory. It will aid in creating Tricycles, Striders,

You will be implementing the Factory Design Pattern to create Bikes

Your Bike Store will be your factory. It will aid in creating Tricycles, Striders, and Kids Bikes

Bike class:

It will hold variables to keep track of the bike name, price, number of wheels, and whether or not it has pedals or training wheels

createBike -> calls createFrame, addWheels, and addPedals

CreateFrame -> displays "Assembling (name of bike) frame

addWheels -> displays nothing if there are no wheels, Adding x wheel(s), and if applicable, Adding Training Wheels

addPedals -> displays adding Pedals if there are pedals

getPrice -> returns the price of the bike

Tricycle

Here you simply need to set the attributes for a Tricycle.

Tricycles, have 3 wheels, and pedals. They cost 54.95

Strider

Here you simply need to set the attributes for a Strider.

Struders, have 2 wheels, and no pedals. They cost 65.99

KidsBike

Here you simply need to set the attributes for a KidsBike.

KidsBikes, have 2 wheels, pedals, and training wheels. They cost 80.99

UML:

You will be implementing the Factory Design Pattern to create Bikes Your

Driver:

public class BikeStoreDriver {

public void runBikeStore() { BikeStore bikeStore = new BikeStore(); Bike tricycle = bikeStore.orderBike("tricycle"); System.out.println(" ----------------------------------- "); Bike strider = bikeStore.orderBike("strider"); System.out.println(" ----------------------------------- "); Bike kidsBike = bikeStore.orderBike("kids bike"); System.out.println(" ----------------------------------- "); } public static void main(String[] args) { BikeStoreDriver driver = new BikeStoreDriver(); driver.runBikeStore(); }

}

Output:

Assembling Tricycle frame Adding 3 wheel(s) Adding pedals Price: $54.95

-----------------------------------

Assembling Strider frame Adding 2 wheel(s) Price: $65.99

-----------------------------------

Assembling Kids Bike frame Adding 2 wheel(s) Adding training wheels Adding pedals Price: $80.99

-----------------------------------

Bike # name: String #price: Double #numWheels: int #hasPeddals: boolean #has Training Wheels: boolean BikeStore + orderBike(String type): Bike - createBike(String type): Bike + createBike(): void - CreateFrame(); void - addWheels(): void - addPedals: void + getPrice(): double Tricycle Strider Kids Bike + Tricycle + Strider + KidsBike Bike # name: String #price: Double #numWheels: int #hasPeddals: boolean #has Training Wheels: boolean BikeStore + orderBike(String type): Bike - createBike(String type): Bike + createBike(): void - CreateFrame(); void - addWheels(): void - addPedals: void + getPrice(): double Tricycle Strider Kids Bike + Tricycle + Strider + KidsBike

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 Databases Questions!