-
Notifications
You must be signed in to change notification settings - Fork 0
/
test4.txt
88 lines (68 loc) · 1.43 KB
/
test4.txt
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
program test4;
var fast: bool = false;
class Car {
attributes
private var motorNum: int;
var color: float;
var fast: bool;
var tires: [4]int;
init() {
var x: int;
var fast: bool = false;
x = 8 * 2;
motorNum = 1000;
self.fast = true;
if (self.fast) {
color = 1.0;
}
tires[0] = 3;
}
methods
function start(a: int) void {
write(color);
stop();
}
private function stop() void {
write(getMotorNum());
}
function setMotorNum(motorNum: int) void {
self.motorNum = motorNum;
}
function getMotorNum() int {
return motorNum;
}
function getTires(index: int) int {
return self.tires[index];
}
};
function getInt() int {
return 7;
}
function fast() bool {
return true;
}
function writeInt(a: int) void {
write(a + 1);
}
function add(a: int, b: int) int {
return a + b;
}
main() {
var c: Car = new Car();
var car: Car;
var arr: [2]int;
arr[0] = -10;
arr[1] = 90;
car = new Car();
c.setMotorNum(2021);
write(c.getMotorNum());
car.setMotorNum(1999 - 1);
write(car.getMotorNum());
car.setMotorNum(c.getMotorNum());
write(car.getMotorNum());
writeInt(car.getMotorNum() + add(getInt(),2));
write(car.getMotorNum());
car.tires[3] = 35;
write(car.tires[3]);
writeInt(arr[0]);
}