//Regular Lecture 21: 28 Oct 2022
//Topic 13//* inheritance: concept of parent & child *//
//example 1
class Father{
constructor(N,Sn){
this.Name = N
this.Surname = Sn
}
}
let rohit = new Father("rohit", "sharma")
console.log(rohit)
class Son extends Father{
constructor(N,Sn,Mn){
super(N,Sn)
this.MyName = Mn
}
}
let Rahul = new Son("Rahul", "Dravid", "Ramesh")
console.log(Rahul)
class Grandson extends Son{
constructor(N,Sn,Mn,Ci){
super(N,Sn,Mn)
this.city = Ci
}
}
let Mahendra = new Grandson("Mahendra", "Singh", "Dhoni", "Ranchi")
console.log(Mahendra)
//example 2
class form1{
constructor(fn,ln){
this.firstName = fn
this.lastName = ln
}
}
let ram = new form1("ram", "yadav")
console.log(ram)
class form2 extends form1{
constructor(fn,ln,mn){
super(fn,ln)
this.midname = mn
}
}
let sham = new form2("sham", "jadhav", "sambhaji")
console.log(sham)
// example 3
class form11{
constructor(c,d){
this.city = c
this.district = d
}
}
let A = new form11("tuljapur", "dharashiv")
console.log(A)
class form12 extends form11{
constructor(c,d){
super(c,d)
}
}
let B = new form12("umaraga", "dharashiv")
console.log(B)
टिप्पण्या
टिप्पणी पोस्ट करा
आपल्या प्रतिक्रियेबद्दल धन्यवाद ! आम्ही लवकरात लवकर प्रतिक्रियेला उत्तर देण्याचा प्रयत्न करू