-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMotorcycle.java
More file actions
112 lines (100 loc) · 2.77 KB
/
Motorcycle.java
File metadata and controls
112 lines (100 loc) · 2.77 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package model;
/**
* Represents a Motorcycle with properties such as year, make, and model.
* This class provides methods to get and set these properties, as well as
* methods for generating noise and obtaining a string representation of the motorcycle.
*
* @author Corbin Goodman - cgoodman4
* CIS175 - Fall 2023
* Aug 29, 2023
*/
public class Motorcycle {
// Fields representing the properties of the motorcycle
private int year; // The year of the motorcycle
private String make; // The make (brand) of the motorcycle
private String model; // The model name of the motorcycle
/**
* Default constructor to create an empty Motorcycle object.
*/
public Motorcycle() {
super();
}
/**
* Constructs a Motorcycle object with the provided year, make, and model.
*
* @param year The year of the motorcycle
* @param make The make (brand) of the motorcycle
* @param model The model name of the motorcycle
*/
public Motorcycle(int year, String make, String model) {
super();
this.year = year;
this.make = make;
this.model = model;
}
/**
* Get the year of the motorcycle.
*
* @return The year of the motorcycle
*/
public int getYear() {
return year;
}
/**
* Set the year of the motorcycle.
*
* @param year The year of the motorcycle
*/
public void setYear(int year) {
this.year = year;
}
/**
* Get the make (brand) of the motorcycle.
*
* @return The make of the motorcycle
*/
public String getMake() {
return make;
}
/**
* Set the make (brand) of the motorcycle.
*
* @param make The make of the motorcycle
*/
public void setMake(String make) {
this.make = make;
}
/**
* Get the model name of the motorcycle.
*
* @return The model name of the motorcycle
*/
public String getModel() {
return model;
}
/**
* Set the model name of the motorcycle.
*
* @param model The model name of the motorcycle
*/
public void setModel(String model) {
this.model = model;
}
/**
* Generate a string representation of the motorcycle.
*
* @return A formatted string describing the motorcycle
*/
@Override
public String toString() {
return String.format("This motorcycle is a %d %s %s", this.year, this.make, this.model);
}
/**
* Generate the sound of the motorcycle engine.
*
* @return The sound of the motorcycle engine
*/
public String makeNoise() {
return "vroom vroom";
}
}