| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | export class Hero { | 
					
						
							|  |  |  |   public id:number | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   constructor( | 
					
						
							|  |  |  |     public firstName:string, | 
					
						
							|  |  |  |     public lastName?:string, | 
					
						
							|  |  |  |     public birthdate?:Date, | 
					
						
							|  |  |  |     public url?:string, | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |     public rate:number = 100, | 
					
						
							|  |  |  |     id?:number) { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   | 
					
						
							|  |  |  |      this.id = id != null ? id : Hero.nextId++; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |   static clone({firstName, lastName, birthdate, url, rate, id} : Hero){ | 
					
						
							|  |  |  |     return new Hero (firstName, lastName, birthdate, url, rate, id ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   get fullName() {return `${this.firstName} ${this.lastName}`;} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static nextId = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static MockHeroes = [ | 
					
						
							|  |  |  |     new Hero( | 
					
						
							|  |  |  |       'Hercules', | 
					
						
							|  |  |  |       'Son of Zeus', | 
					
						
							|  |  |  |       new Date(1970, 1, 25), | 
					
						
							|  |  |  |       'http://www.imdb.com/title/tt0065832/', | 
					
						
							|  |  |  |       325), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     new Hero('eenie', 'toe'), | 
					
						
							|  |  |  |     new Hero('Meanie', 'Toe'), | 
					
						
							|  |  |  |     new Hero('Miny', 'Toe'), | 
					
						
							|  |  |  |     new Hero('Moe', 'Toe') | 
					
						
							|  |  |  |   ]; | 
					
						
							|  |  |  | } |