/
TestOOP.js
94 lines (67 loc) · 2.11 KB
/
TestOOP.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Type.registerNamespace('Test');
Type.registerNamespace('Test.More');
////////////////////////////////////////////////////////////////////////////////
// Test.IMammal
Test.IMammal = function() { };
Test.IMammal.prototype = {
}
Test.IMammal.registerInterface('Test.IMammal');
////////////////////////////////////////////////////////////////////////////////
// Test.IPet
Test.IPet = function() { };
Test.IPet.prototype = {
get_name : null,
get_owner : null
}
Test.IPet.registerInterface('Test.IPet');
////////////////////////////////////////////////////////////////////////////////
// Test.Animal
Test.Animal = function Test_Animal(species) {
this._species = species;
}
Test.Animal.prototype = {
_species: null,
get_species: function Test_Animal$get_species() {
return this._species;
}
}
////////////////////////////////////////////////////////////////////////////////
// Test.Cat
Test.Cat = function Test_Cat() {
Test.Cat.initializeBase(this, [ 'Cat' ]);
}
Test.Cat.prototype = {
speak: function Test_Cat$speak() {
return 'meow';
}
}
////////////////////////////////////////////////////////////////////////////////
// Test.Garfield
Test.Garfield = function Test_Garfield() {
Test.Garfield.initializeBase(this);
}
Test.Garfield.prototype = {
get_name: function Test_Garfield$get_name() {
return 'Garfield';
},
get_owner: function Test_Garfield$get_owner() {
return 'Jon';
},
speak: function Test_Garfield$speak() {
return Test.Garfield.callBaseMethod(this, 'speak') + '\r\n' + 'I am fat, lazy, and cynical, but still, a favorite cat...';
}
}
////////////////////////////////////////////////////////////////////////////////
// Test.More.Comic
Test.More.Comic = function(name) {
this._name = name;
}
Test.More.Comic.prototype = {
get_name: function() {
return this._name;
}
}
Test.Animal.registerClass('Test.Animal');
Test.Cat.registerClass('Test.Cat', Test.Animal, Test.IMammal);
Test.Garfield.registerClass('Test.Garfield', Test.Cat, Test.IPet);
Test.More.Comic.registerClass('Test.More.Comic');