-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathdebugger_test.obs
More file actions
56 lines (45 loc) · 966 Bytes
/
debugger_test.obs
File metadata and controls
56 lines (45 loc) · 966 Bytes
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
class Counter {
@count : Int;
New() {
@count := 0;
}
method : public : Increment() ~ Nil {
@count += 1;
}
method : public : GetCount() ~ Int {
return @count;
}
method : public : ToString() ~ String {
return "Counter={$@count}";
}
}
class Main {
function : Main(args : String[]) ~ Nil {
values := Int->New[5];
each(i : values) {
values[i] := i * 10;
};
sum := 0;
each(i : values) {
sum += values[i];
};
counter := Counter->New();
counter->Increment();
counter->Increment();
counter->Increment();
msg := counter->ToString();
count := counter->GetCount();
"Sum={$sum}, {$msg}"->PrintLine();
if(count > 2) {
"Count is greater than 2"->PrintLine();
};
result := Factorial(5);
"Factorial(5)={$result}"->PrintLine();
}
function : Factorial(n : Int) ~ Int {
if(n <= 1) {
return 1;
};
return n * Factorial(n - 1);
}
}