Created
November 2, 2015 20:19
-
-
Save samueleresca/1fce4d97db00faf6ddd2 to your computer and use it in GitHub Desktop.
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
class Telefilm { | |
title : string; | |
description: string; | |
characters: Character[]; | |
constructor( title: string, description: string, characters: Character[]) { | |
this.title= title; | |
this.description= description; | |
this.characters= characters; | |
} | |
toString() : string{ | |
var characterStr=""; | |
this.characters.forEach((cha) =>{ characterStr+= cha.toString() + "<br/>";}); | |
return "<b>"+this.title +" "+this.description+"</b><br/>" +characterStr; | |
} | |
} | |
class Character{ | |
name: string; | |
surname: string; | |
constructor(name: string, surname: string){ | |
this.name=name; | |
this.surname=surname; | |
} | |
toString() : string{ | |
return this.name +" "+ this.surname; | |
} | |
} | |
var listCharacter:Array<Character> = [ | |
new Character("John","Dorian"), | |
new Character("Elliot","Reid"), | |
new Character("Carla","Espinosa") | |
]; | |
var telefilm= new Telefilm("Scrubs","Medical situations", listCharacter); | |
document.body.innerHTML = telefilm.toString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment