Add a couple of Lox samples
This commit is contained in:
parent
69a9a95483
commit
8450ae6db8
2 changed files with 23 additions and 0 deletions
15
src/coffee.lox
Normal file
15
src/coffee.lox
Normal 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
8
src/scone.lox
Normal file
|
@ -0,0 +1,8 @@
|
|||
class Scone {
|
||||
topping(first, second) {
|
||||
print "scone with " + first + " and " + second;
|
||||
}
|
||||
}
|
||||
|
||||
var scone = Scone();
|
||||
scone.topping("berries", "cream");
|
Loading…
Reference in a new issue