Classes 12

This commit is contained in:
nazrin 2025-06-02 22:22:04 +00:00
parent 52a7b73a9e
commit d8ac625429
18 changed files with 417 additions and 186 deletions

21
test/class.lox Normal file
View file

@ -0,0 +1,21 @@
class Cake{
init(goodness){
this.adjective = this.rate(goodness);
}
rate(goodness){
if(goodness)
return "delicious";
else
return "horrendous";
}
taste(){
print "The " + this.flavor + " cake is " + this.adjective + "!";
}
}
var cake = Cake(true);
cake.flavor = "German chocolate";
var t = cake.taste;
t();