-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram1.lox
More file actions
66 lines (54 loc) · 1016 Bytes
/
program1.lox
File metadata and controls
66 lines (54 loc) · 1016 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
57
58
59
60
61
62
63
64
65
66
/*fun hello (n){
if (n <= 0){
println (n);
}else{
hello (n - 1);
println (n);
}
}
hello (5);*/
/*class Bacon {
eat(n) {
print ("Crunch crunch crunch!: " + n);
}
}
Bacon().eat(23);*/
/*class Cake {
taste() {
var adjective = "delicious";
print ("The " + this.flavor + " cake is " + adjective + "!");
}
}
var cake = Cake();
cake.flavor = "German chocolate";
cake.taste(); // Prints "The German chocolate cake is delicious!".*/
/*class Thing {
getCallback() {
fun localFunction() {
print (this);
}
return localFunction;
}
}
var callback = Thing().getCallback();
callback();*/
class Hello {
init (a, b) {
this.a = a;
this.b = b;
}
multiplied () {
return this.a * this.b;
}
hi (n){
if (n <= 0){
println (n);
}else{
this.hi (n - 1);
println (n);
}
}
}
println (Hello(2, 4).multiplied());
var hello = Hello(0, 0);
hello.hi(5);