コンポジション
️継承より使いやすいのでおすすめbsahd.icon
code:サンプル.ts
// コンポジションされる側
class Tire{
// 割愛
}
class Engine{
// 割愛
}
// コンポジションする側
class Car{
tire:Tire;
engine:Engine;
constructor(){
this.tire = new Tire();
this.engine = new Engine();
}
}