Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

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

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago