class PersonInformation{
constructor(IQ, hobby, favoriteColor, weight, height, e_mail, score, penalty){
this.IQ = IQ;
this.hobby = hobby;
this.favoriteColor = favoriteColor;
this.weight = weight;
this.height = height;
this.e_mail = e_mail;
this.score = score;
this.penalty = penalty;
}
testresult(){
return this.score - this.penalty;
}
}
class PersonInformationPlus extends PersonInformation{
constructor(IQ, hobby, favoriteColor, weight, height, e_mail, score, penalty, plusScore){
super(IQ, hobby, favoriteColor, weight, height, e_mail, score, penalty);
this.plusScore = plusScore;
}
testresult() {return super.testresult() + this.plusScore }
e_mailId() {return this.e_mail.split('@')[0]}
}
const devil = new PersonInformationPlus(300,'trouble','red','none','none','devil@hell.devil',80,0,5);
console.log(devil);
console.log('devil.testresult : ', devil.testresult());
console.log(devil.e_mailId());
const jyo = {
IQ: 120,
score: 90,
penalty: 10,
plusScore: 3,
testResult: function(){
return this.score - this.penalty + this.plusScore;
}
}
const jung = {
IQ: 130,
score: 95,
penalty: 8,
plusScore: 5,
}
jung.__proto__ = jyo;
const Ann = Object.create(jyo);
Ann.IQ = 140;
Ann.score = 100;
Ann.penalty = 5;
Ann.plusScore = 10;
console.log(jung.testResult());
console.log(Ann.testResult());