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
Showing
2 changed files
with
114 additions
and
0 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,46 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<title>Oop.JS: Object Oriented JavaScript Class Library</title> | |||
</head> | |||
<body> | |||
<script src="oop.js"></script> | |||
<script> | |||
var Animal = oop.Class("Animal") | |||
.construct(function (name) { | |||
this.name = name; | |||
}) | |||
.method("sleep", function () { | |||
alert("ZzZzZzZzZzZzZzZzZz"); | |||
}) | |||
.build(); | |||
|
|||
var Cat = oop.Class("Cat") | |||
.extends(Animal) | |||
.method("purr", function () { | |||
alert("purrrrrrrrrrrrr"); | |||
}) | |||
.build(); | |||
|
|||
var Dog = oop.Class("Dog") | |||
.extends(Animal) | |||
.method("bark", function () { | |||
alert("Wua bark woop arf"); | |||
}) | |||
.build(); | |||
|
|||
|
|||
var lilo = new Cat("Lilo"); | |||
var luz = new Dog("Luz"); | |||
|
|||
alert(lilo.name); // Lilo | |||
alert(luz.name); // Luz | |||
|
|||
lilo.sleep(); // ZzZzZzZzZzZzZzZzZz | |||
luz.sleep(); // ZzZzZzZzZzZzZzZzZz | |||
|
|||
lilo.purr(); // purrrrrrrrrrrrr | |||
luz.bark(); // Wua bark woop arf | |||
</script> | |||
</body> | |||
</html> |
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