added doga
This commit is contained in:
69
24_11_11_doga/Feladat3.js
Normal file
69
24_11_11_doga/Feladat3.js
Normal file
@@ -0,0 +1,69 @@
|
||||
class Uvegautomata{
|
||||
static uvegDarabszam = 0;
|
||||
|
||||
constructor(maxKapacitas){
|
||||
this.maxKapacitas = maxKapacitas;
|
||||
}
|
||||
|
||||
uvegek = {
|
||||
szines: 0,
|
||||
atlatszo : 0
|
||||
}
|
||||
|
||||
uvegBehelyez(tipus){
|
||||
let currentCapacity = this.uvegek.szines + this.uvegek.atlatszo;
|
||||
if(currentCapacity < this.maxKapacitas){
|
||||
if(tipus == "színes"){
|
||||
this.uvegek.szines++;
|
||||
Uvegautomata.uvegDarabszam++;
|
||||
} else if(tipus == "átlátszó"){
|
||||
this.uvegek.atlatszo++;
|
||||
Uvegautomata.uvegDarabszam++;
|
||||
} else{
|
||||
console.log("Az üveg nem a megfelelő típusú!");
|
||||
}
|
||||
} else{
|
||||
console.log("Az automata tele van!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
kapacitasEllenorzes(){
|
||||
let currentCapacity = this.uvegek.szines + this.uvegek.atlatszo;
|
||||
return `Bedobott üvegek: ${currentCapacity}, Ennyi hely van még az automatában: ${this.maxKapacitas - currentCapacity}`;
|
||||
}
|
||||
|
||||
kiurit(){
|
||||
this.uvegek.atlatszo = 0;
|
||||
this.uvegek.szines = 0;
|
||||
|
||||
return "Autómata kiürítve!";
|
||||
}
|
||||
}
|
||||
|
||||
let automata = new Uvegautomata(10);
|
||||
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
|
||||
//típus ellenőrzés tesztelés
|
||||
automata.uvegBehelyez("fekete");
|
||||
|
||||
|
||||
//Max limit tesztelés
|
||||
/*
|
||||
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
*/
|
||||
console.log(automata.kapacitasEllenorzes());
|
||||
console.log(automata.kiurit());
|
||||
console.log(automata.kapacitasEllenorzes());
|
||||
Reference in New Issue
Block a user