Add a couple of Lox samples

This commit is contained in:
Tom Willemse 2022-08-14 23:44:45 -07:00
parent 69a9a95483
commit 8450ae6db8
2 changed files with 23 additions and 0 deletions

15
src/coffee.lox Normal file
View file

@ -0,0 +1,15 @@
class CoffeeMaker {
init(coffee) {
this.coffee = coffee;
}
brew() {
print "Enjoy your cup of " + this.coffee;
// No reusing the grounds!
this.coffee = nil;
}
}
var maker = CoffeeMaker("coffee and chicory");
maker.brew();

8
src/scone.lox Normal file
View file

@ -0,0 +1,8 @@
class Scone {
topping(first, second) {
print "scone with " + first + " and " + second;
}
}
var scone = Scone();
scone.topping("berries", "cream");