Created
September 1, 2019 06:59
-
-
Save ThomRoman/c2027a50da941c70a3a8443bd6bf43dd 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 Course{ | |
constructor(private _id:number,private _name:string){ | |
} | |
get id(){ | |
return this._id | |
} | |
set id(id:number){ | |
this._id=id | |
} | |
} | |
class School { | |
private courses:Course[] | |
constructor(private _name:string){ | |
this.courses = [] | |
} | |
get name(){ | |
return this._name | |
} | |
set name(name:string){ | |
this._name=name | |
} | |
addCourse(course:Course):void{ | |
this.courses.push(course) | |
} | |
} | |
class University extends School{ | |
constructor(name:string,private web:string){ | |
super(name) | |
} | |
} | |
let school:University | |
school = new University('U','u.com') | |
school.addCourse(new Course(1,'JS')) | |
console.log(school) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment