-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from Robotnik08/development
Classes
- Loading branch information
Showing
18 changed files
with
379 additions
and
40 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
define object playerMaker (string name, string position, int number) { | ||
const player = { | ||
name, position, number | ||
} | ||
class Person (name, age) { | ||
set self->name = name | ||
set self->age = age | ||
|
||
set player->greet = void () => { | ||
do sayln(`Hello, I'm {player->name} and I play as {player->position} ({player->number})`) | ||
implement greet () { | ||
do sayln(`Hello, my name is {self->name}. I am {self->age} years old`) | ||
} | ||
} | ||
|
||
class Student (name, age, grade) { | ||
set self += Person(name, age) | ||
set self->grade = grade | ||
|
||
return player | ||
implement sayGrade () { | ||
do sayln(`My grade is {self->grade}`) | ||
} | ||
} | ||
|
||
make object player1 = playerMaker("Bib", "Attacker", 10) | ||
make object player2 = playerMaker("Bob", "Defender", 5) | ||
make student1 = Student("Bob", 20, "A") | ||
|
||
do student1->greet() | ||
do student1->sayGrade() | ||
|
||
make student2 = Student("Bib", 21, "B") | ||
|
||
do player1->greet() | ||
do player2->greet() | ||
do student2->greet() | ||
do student2->sayGrade() |
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
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
Oops, something went wrong.