forked from coderfin/typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
50 lines (40 loc) · 1.9 KB
/
app.ts
File metadata and controls
50 lines (40 loc) · 1.9 KB
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
import MDefinitions = module('definitions'); // includes jquery, backbone and underscore/lodash
import MAnimal = module('polymorphism/Animal');
import MAnimalia = module('polymorphism/Animalia');
import MHanoi = module('hanoi/Hanoi');
import MMagazineRack = module('collections/dynamiclinkedlist/MagazineRack');
export function main(): void {
/* polymorphism example */
console.log('\n\nSTART POLYMORPHISM EXAMPLE');
var animals: MAnimal.Animal[] = [];
animals.push(new MAnimalia.Types.Dog());
var japaneseDog: MAnimalia.Types.Dog = new MAnimalia.Types.Dog('wan-wan');
japaneseDog.commonName = 'Japanese dog';
japaneseDog.imageUri = '//upload.wikimedia.org/wikipedia/commons/thumb/7/78/Akita_inu.jpeg/220px-Akita_inu.jpeg';
animals.push(japaneseDog);
animals.push(new MAnimalia.Types.Cat());
animals.push(new MAnimalia.Types.Lion());
animals.push(new MAnimalia.Types.Penguin());
animals.forEach((animal) => {
var section = document.createElement('section');
section.innerHTML = '<img src="' + animal.imageUri + '" alt="' + animal.species + '" />' +
'<p>' + animal.talk() + '</p>';
document.getElementById('animals').appendChild(section);
});
console.log('END POLYMORPHISM EXAMPLE');
/* class example */
console.log('\n\nSTART HANOI EXAMPLE');
var towers: MHanoi.Hanoi = new MHanoi.Hanoi(4);
towers.solve();
console.log('END HANOI EXAMPLE');
/* dynamic linked list example */
console.log('\n\nSTART DYNAMIC LINKED LIST EXAMPLE');
MMagazineRack.MagazineRack.main();
console.log('END DYNAMIC LINKED LIST EXAMPLE');
/* definitions example */
console.log('\n\nSTART DEFINITIONS EXAMPLE');
_.each([3, 2, 3, 5, 6, 7], function (i) {
console.log('Definition Example: ', i);
});
console.log('END DEFINITIONS EXAMPLE');
}