Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int claveApertura;
- public int cantFallos; //maxima cantidad de fallos posibles
- public int cantExitosas = 0; //contador aperturas exitosas
- public int cantFallidas = 0; //contador aperturas fallidas
- private boolean estado; //abierto / cerrado
- private boolean bloqueada = false;
- public Cerradura(int claveApertura, int cantFallos){
- this.claveApertura = claveApertura;
- this.cantFallos = cantFallos;
- }
- public void abrir(int claveApertura){
- if(this.bloqueada == false){
- if(this.claveApertura == claveApertura){
- this.estado = true;
- this.cantExitosas += 1;
- }
- else
- {
- this.estado = false;
- if(this.cantFallidas < this.cantFallos)
- this.cantFallidas += 1;
- else
- this.bloqueada = true;
- }
- }
- System.out.println(this.cantFallidas);
- System.out.println(this.bloqueada);
- }
- public void cerrar(){
- this.estado = false;
- }
- public boolean estaAbierta(){
- return this.estado == true ? true : false;
- }
- public boolean estaCerrado(){
- return this.estado == false ? true : false;
- }
- public boolean estaBloqueada(){
- return this.bloqueada;
- }
- public int cantidadExitosas(){
- return this.cantExitosas;
- }
- public int cantidadFallidas(){
- return this.cantFallidas;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement