Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Album
- {
- constructor(cim = 'Untitled')
- {
- this.cim = cim
- this.hossz = 0
- this.zenek = []
- }
- get cim()
- {
- return this._cim
- }
- set cim(cim)
- {
- this._cim = typeof cim == 'string' && cim.length >= 3 ? cim : 'Unknown'
- }
- zenetFelvesz(zene)
- {
- if (typeof zene == 'object' && zene.hasOwnProperty('zeneCim') && zene.hasOwnProperty('zeneHossz')) {
- this.zenek.push(zene.zeneCim)
- this.hossz += zene.zeneHossz
- }
- }
- albumHossz()
- {
- return `${ Math.floor(this.hossz / 60) } perc, ${ this.hossz % 60 } masodperc`
- }
- info()
- {
- return `${ this.cim } album, ${ this.zenek.length } darab zenevel`
- }
- osszehasonlit(masik)
- {
- return masik instanceof Album && this.cim == masik.cim && this.hossz == masik.hossz && this.zenek.every((cim, index) => cim == masik.zenek[index])
- }
- randomZene()
- {
- return this.zenek.length ? this.zenek[Math.floor(Math.random() * this.zenek.length)] : 'Ures album!'
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement