Advertisement
Guest User

Untitled

a guest
Sep 4th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.93 KB | None | 0 0
  1. public int claveApertura;
  2.         public int cantFallos; //maxima cantidad de fallos posibles
  3.         public int cantExitosas = 0; //contador aperturas exitosas
  4.         public int cantFallidas = 0; //contador aperturas fallidas
  5.         private boolean estado; //abierto / cerrado
  6.         private boolean bloqueada = false;
  7.        
  8.         public Cerradura(int claveApertura, int cantFallos){
  9.                 this.claveApertura = claveApertura;
  10.                 this.cantFallos = cantFallos;
  11.         }
  12.        
  13.         public void abrir(int claveApertura){
  14.                 if(this.bloqueada == false){
  15.                         if(this.claveApertura == claveApertura){
  16.                                 this.estado = true;
  17.                                 this.cantExitosas += 1;
  18.                         }
  19.                         else
  20.                         {
  21.                                 this.estado = false;
  22.                                 if(this.cantFallidas < this.cantFallos)
  23.                                         this.cantFallidas += 1;
  24.                                 else
  25.                                         this.bloqueada = true;
  26.                         }
  27.                 }
  28.                 System.out.println(this.cantFallidas);
  29.                 System.out.println(this.bloqueada);
  30.         }
  31.        
  32.         public void cerrar(){
  33.                 this.estado = false;
  34.         }
  35.        
  36.         public boolean estaAbierta(){
  37.                 return this.estado == true ? true : false;
  38.         }
  39.        
  40.         public boolean estaCerrado(){
  41.                 return this.estado == false ? true : false;
  42.         }
  43.        
  44.         public boolean estaBloqueada(){
  45.                 return this.bloqueada;
  46.         }
  47.        
  48.         public int cantidadExitosas(){
  49.                 return this.cantExitosas;
  50.         }
  51.        
  52.         public int cantidadFallidas(){
  53.                 return this.cantFallidas;
  54.         }      
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement