Skip to content

Instantly share code, notes, and snippets.

@ThomRoman
Created September 1, 2019 06:59
Show Gist options
  • Save ThomRoman/c2027a50da941c70a3a8443bd6bf43dd to your computer and use it in GitHub Desktop.
Save ThomRoman/c2027a50da941c70a3a8443bd6bf43dd to your computer and use it in GitHub Desktop.
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