✏️4.2 테스트할 샘플 코드
// Province 클래스
constructor(doc) {
this.name = doc.name;
this._producers = [];
this._totalProduction = 0;
this.demand = doc.demand;
this._price = doc.price;
doc.producers.forEach(d => this.addProducer(new Producer(this, d)));
}
addProducer(arg) {
this._producers.push(arg);
this._totalProduction += arg.production;
}// 최상위
function sampleProvinceData() {
return {
name: "Asia",
producers: [
{name: "Byzantium", const: 10, production: 9},
{name: "Attalia", const: 12, production: 10},
{name: "Sinope", const: 10, production: 6},
],
demane: 30,
price: 20
};
}
Last updated