Created
April 26, 2013 23:16
-
-
Save delucas/5471052 to your computer and use it in GitHub Desktop.
UNLaM - Ejercicios de clase - Objetos, 25/04/2013
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ar.edu.unlam.tallerweb; | |
public class Adivinanza { | |
private Integer numero; | |
public Adivinanza(Integer numero) { | |
this.numero = numero; | |
} | |
public Boolean adivinar(Integer numero) { | |
return numero == this.numero; | |
} | |
public Boolean esMasGrandeQue(Integer numero) { | |
return this.numero > numero; | |
} | |
public Boolean esMasChicoQue(Integer numero) { | |
return this.numero < numero; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ar.edu.unlam.tallerweb; | |
public class CerraduraElectronica { | |
private Integer clave; | |
private Boolean abierta = false; | |
public CerraduraElectronica(Integer clave) { | |
this.clave = clave; | |
} | |
public void abrir(Integer clave) { | |
if (clave == this.clave) { | |
this.abierta = true; | |
} | |
} | |
public void cerrar(Integer clave) { | |
if (clave == this.clave) { | |
this.abierta = false; | |
} | |
} | |
public Boolean estaAbierta() { | |
return this.abierta; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ar.edu.unlam.tallerweb; | |
public class Dado { | |
private Integer caras; | |
public Dado(Integer caras) { | |
this.caras = caras; | |
} | |
public Integer getCaras() { | |
return this.caras; | |
} | |
public Integer tirar() { | |
return (int) (Math.random() * this.caras) + 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ar.edu.unlam.tallerweb; | |
public class Nota { | |
private Integer nota; | |
public Nota(Integer nota) { | |
this.nota = nota; | |
} | |
public Boolean estaAprobado() { | |
return nota >= 4; | |
} | |
public Boolean estaPromocionado() { | |
return nota >= 7; | |
} | |
public Boolean estaReprobado() { | |
return nota < 4; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ar.edu.unlam.tallerweb; | |
class Subasta { | |
private Integer valor = 0; | |
private Boolean abierta = true; | |
Subasta(Integer valorInicial) { | |
this.valor = valorInicial; | |
} | |
void nuevaOferta(Integer oferta) { | |
if (this.abierta && oferta > this.valor) { | |
this.valor = oferta; | |
} | |
} | |
Integer cerrar() { | |
this.abierta = false; | |
return this.valor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment