-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
45 lines (42 loc) · 1.26 KB
/
Main.java
File metadata and controls
45 lines (42 loc) · 1.26 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
class Motorcycle {
String make;
String color;
boolean engineState;
void startEngine() {
if (engineState == true) {
System.out.println("The engine is already on.");
} else {
engineState = true;
System.out.println("The engine is now on.");
}
}
void showAtts() {
System.out.println("This motorcycle is a " + color + " " + make);
if (engineState == true) {
System.out.println("The engine is on.");
} else {
System.out.println("The engine is off.");
}
}
}
public class Main {
public static void main(String args[]) {
Motorcycle m = new Motorcycle();
m.make = "Yamaha RZ350";
m.color = "yellow";
System.out.println("Calling showAtts...");
m.showAtts();
System.out.println("-----");
System.out.println("Starting engine...");
m.startEngine();
System.out.println("-----");
System.out.println("Calling showAtts...");
m.showAtts();
System.out.println("-----");
System.out.println("Starting engine...");
m.startEngine();
System.out.println("-----");
System.out.println("Calling showAtts...");
m.showAtts();
}
}