-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bike.java
50 lines (44 loc) · 1.16 KB
/
Bike.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* bike class that creates bike according to bike specifications
*
* @author nathan
*/
public class Bike {
protected String name;
protected double price;
protected int numWheels;
protected boolean hasPeddals;
protected boolean hasTrainingWheels;
/** creates bike by adding frame, wheels, and pedals */
public void createBike() {
createFrame();
addWheels();
addPedals();
}
/** adds frame according to bike type */
private void createFrame() {
System.out.println("Assembling " + name + " frame");
}
/**
* adds wheels according to number of wheels and if there are training wheels
*/
private void addWheels() {
if (numWheels == 0)
return;
System.out.println("Adding " + numWheels + " wheel(s)");
if (hasTrainingWheels)
System.out.println("Adding training wheels");
}
/** adds pedals if there are pedals */
private void addPedals() {
if (hasPeddals)
System.out.println("Adding pedals");
}
/**
*
* @return price of bike
*/
public double getPrice() {
return price;
}
}