JavaScript ၌ OOP အဆင့်ဆင့်အမွေဆက်ခံခြင်း
ကိုယ်ပိုင်အမွေခံ class တစ်ခုမှ ထပ်မံအမွေဆက်ခံနိုင်ပါသည်။ ဥပမာတစ်ခုအားဖြင့် ကြည့်ကြပါစို့။ ကျွန်ုပ်တို့တွင် အောက်ပါ မိဘ class တစ်ခုရှိသည်ဆိုပါစို့။
class User {
setName(name) {
this._name = name;
}
getName() {
return this._name;
}
}
ဤ class မှ အောက်ပါ class သည် အမွေဆက်ခံပါသည်။
class Student extends User {
setYear(year) {
this._year = year;
}
getYear() {
return this._year;
}
}
ဤ class မှ နောက်ထပ် class တစ်ခုက အမွေဆက်ခံပါသည်။
class StudentProgrammer extends Student {
setSkill(skill) {
this._skill = skill;
}
getSkill() {
return this._skill;
}
}
User class မှ အမွေဆက်ခံမည့်
Employee class ကို ဖန်တီးပါ။
Employee class မှ အမွေဆက်ခံမည့်
Programmer class ကို ဖန်တီးပါ။
Employee class မှ အမွေဆက်ခံမည့်
Designer class ကို ဖန်တီးပါ။
သင် ဖန်တီးထားသော class များအတွင်း မတူညီသော method များကို ထည့်သွင်းပါ။