Classes 12
This commit is contained in:
parent
52a7b73a9e
commit
d8ac625429
18 changed files with 417 additions and 186 deletions
21
test/class.lox
Normal file
21
test/class.lox
Normal 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();
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue