-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Berezin
committed
Jun 15, 2019
1 parent
b43415d
commit 2d44ce6
Showing
6 changed files
with
97 additions
and
32 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
// Class Example | ||
class Lox { | ||
breakfast() { | ||
print "Toast"; | ||
this.hello = "toast"; | ||
return this.hello; | ||
class Doughnut { | ||
init(name) { | ||
this.name = name; | ||
} | ||
} | ||
|
||
fun hello () { | ||
print "Would you like some breakfast?"; | ||
cook() { | ||
var name = ""; | ||
if (this.name) { | ||
name = this.name + " "; | ||
} | ||
print "You fry the " + name + "Doughnut until golden brown."; | ||
} | ||
} | ||
|
||
print Lox; | ||
class BostonCream < Doughnut { | ||
init() { | ||
super.init("Boston Cream"); | ||
} | ||
} | ||
|
||
print hello; | ||
var loxInstance = Lox(); | ||
Doughnut("Cruller").cook(); | ||
|
||
loxInstance.category = "Breakfast"; | ||
print loxInstance.category; | ||
print loxInstance.breakfast(); | ||
BostonCream().cook(); | ||
|
||
print Lox(); | ||
fun hello () { | ||
print "Would you like some breakfast?"; | ||
} | ||
|
||
// class Bagel {} | ||
// var bagel = Bagel(); | ||
// print bagel; // Prints "Bagel instance". | ||
// print bagel.lox; | ||
print BostonCream; | ||
print Doughnut; | ||
print BostonCream(); | ||
print hello; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters