-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplicatedObjects.java
More file actions
75 lines (60 loc) · 1.44 KB
/
complicatedObjects.java
File metadata and controls
75 lines (60 loc) · 1.44 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
class p_mainClass {
public static void main(String[] args){
System.out.println(new fakeMain().run());
}
}
class fakeMain {
public int run(){
Vehicle a;
Vehicle b;
int ret;
a = new Vehicle();
b = new Vehicle();
ret = a.create(5, 2);
ret = b.create(2, 10);
ret = a.move();
ret = b.setOn(true);
ret = b.move();
ret = b.setOn(false);
ret = b.move();
ret = a.setOn(true);
ret = a.move();
ret = b.move();
return 0;
}
}
class Vehicle {
int moveSpeed;
int capacity;
boolean on;
public int create(int speed, int xCapacity){
moveSpeed = speed;
capacity = xCapacity;
on = false;
return 0;
}
public int getSpeed(){
return moveSpeed;
}
public int setSpeed(int a){
moveSpeed = a;
return 0;
}
public int setOn(boolean a){
on = a;
return 0;
}
public int move(){
if(on){
System.out.print("Zoom zoom, I went ");
System.out.print(moveSpeed);
System.out.println(" Units!");
System.out.print("And carried ");
System.out.print(capacity);
System.out.println(" Units!\n");
}else{
System.out.println("The car didn't move cause you didn't turn it on\n");
}
return moveSpeed;
}
}