class Clovek {
constructor(jmeno, prijmeni, vek) {
this.jmeno = jmeno
this.prijmeni = prijmeni
this.vek = vek
}
vypis() {
console.log(this.kdoJsi())
}
kdoJsi() {
return `Ahoj, jmenuji se ${this.jmeno} ${this.prijmeni} a je mi ${this.vek} let.`
}
}
const martin = new Clovek("Martin", "Pek", 22)
const beka = new Clovek("Rebeca", "Prochazkova", 20)
const pata = new Clovek("Patrick", "Prochazka", 19)
const ivan = new Clovek("Ivan", "Vlcek", 33)
const lide = []
lide.push(ivan)
lide.push(beka)
lide.push(martin)
lide.push(pata)
lide.pop()
lide.pop()
lide.forEach((clovek, i) => {
console.log(`${i + 1}. ${clovek.kdoJsi()}`)
})
console.log("\npocet lidi v promenne 'lide': " + lide.length)
console.log(lide)