Created
March 29, 2012 02:12
-
-
Save carlossaraiva/2232524 to your computer and use it in GitHub Desktop.
[POO]Trabalho - Exercício 2 (Controle)
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
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* | |
* @author Carlos | |
*/ | |
interface Controle { | |
/** | |
* Interface para os controles que serão usados pelos equipamentos | |
* @param volume volumne é o volume atual do equipamento | |
*/ | |
abstract void aumentaVolume(int volume); | |
abstract void diminuiVolume(int volume); | |
abstract void mudaCanal(int canal); | |
} |
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
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* | |
* @author Carlos | |
*/ | |
public class ControleRemotoTV extends Televisao implements Controle { | |
/** | |
* Aumenta o volume da televisão | |
* | |
* @param volume parametro do volume | |
*/ | |
@Override | |
public void aumentaVolume(int volume) { | |
if (this.volume != 10) { | |
this.volume = volume + 1; | |
} else { | |
this.volume = 10; | |
} | |
} | |
/** | |
* Diminui o volume da televisão | |
* | |
* @param volume parametro do volume | |
*/ | |
@Override | |
public void diminuiVolume(int volume) { | |
if (this.volume != 10) { | |
this.volume = volume - 1; | |
} else { | |
this.volume = 10; | |
} | |
} | |
/** | |
* Muda o canal da televisão | |
* | |
* @param canal parametro do canaol | |
*/ | |
@Override | |
public void mudaCanal(int canal) { | |
this.canal = canal; | |
} | |
} |
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
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* | |
* @author Carlos | |
*/ | |
public class Equipamento { | |
protected int volume; | |
protected boolean estado; | |
/** | |
* Construtor vazio | |
*/ | |
public Equipamento() { | |
} | |
/** | |
* Costrutor que inicializa os atributos de Equipamento | |
* | |
* @param volume define o volume do equipamento | |
* @param estado define o estado do equipamento | |
*/ | |
public Equipamento(int volume, boolean estado) { | |
this.volume = volume; | |
this.estado = estado; | |
} | |
/** | |
* Método de acesso para o atributo Estado | |
* | |
* @return retorna o valor de estado | |
*/ | |
public boolean isEstado() { | |
return estado; | |
} | |
/** | |
* Método modificador de estado | |
* | |
* @param estado modifica o atributo estado | |
*/ | |
public void setEstado(boolean estado) { | |
this.estado = estado; | |
} | |
/** | |
* Método que retorno o valor do atributo volume | |
* | |
* @return retorna o valor do volume | |
*/ | |
public int getVolume() { | |
return volume; | |
} | |
/** | |
* Método modificador do volume | |
* | |
* @param volume modifica o atributo volume | |
*/ | |
public void setVolume(int volume) { | |
this.volume = volume; | |
} | |
/** | |
* Método toString da classe | |
* | |
* @return retorna uma string com os valores do atributo | |
*/ | |
@Override | |
public String toString() { | |
return "Equipamento{" + "volume=" + volume + ", estado=" + estado + '}'; | |
} | |
} |
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
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* | |
* @author Carlos | |
*/ | |
public class Equipamento { | |
protected int volume; | |
protected boolean estado; | |
/** | |
* Construtor vazio | |
*/ | |
public Equipamento() { | |
} | |
/** | |
* Costrutor que inicializa os atributos de Equipamento | |
* | |
* @param volume define o volume do equipamento | |
* @param estado define o estado do equipamento | |
*/ | |
public Equipamento(int volume, boolean estado) { | |
this.volume = volume; | |
this.estado = estado; | |
} | |
/** | |
* Método de acesso para o atributo Estado | |
* | |
* @return retorna o valor de estado | |
*/ | |
public boolean isEstado() { | |
return estado; | |
} | |
/** | |
* Método modificador de estado | |
* | |
* @param estado modifica o atributo estado | |
*/ | |
public void setEstado(boolean estado) { | |
this.estado = estado; | |
} | |
/** | |
* Método que retorno o valor do atributo volume | |
* | |
* @return retorna o valor do volume | |
*/ | |
public int getVolume() { | |
return volume; | |
} | |
/** | |
* Método modificador do volume | |
* | |
* @param volume modifica o atributo volume | |
*/ | |
public void setVolume(int volume) { | |
this.volume = volume; | |
} | |
/** | |
* Método toString da classe | |
* | |
* @return retorna uma string com os valores do atributo | |
*/ | |
@Override | |
public String toString() { | |
return "Equipamento{" + "volume=" + volume + ", estado=" + estado + '}'; | |
} | |
} |
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
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* | |
* @author Carlos | |
*/ | |
public class Televisao extends Equipamento implements Controle { | |
protected int canal; | |
public Televisao() { | |
this.volume = 3; | |
this.estado = true; | |
this.canal = 2; | |
} | |
public Televisao(int canal, int volume, boolean estado) { | |
super(volume, estado); | |
this.canal = canal; | |
} | |
public void desligaTV(){ | |
this.volume = 0; | |
this.estado = false; | |
this.canal = 0; | |
} | |
public int getCanal() { | |
return canal; | |
} | |
public void setCanal(int canal) { | |
this.canal = canal; | |
} | |
/** | |
* Aumenta o volume da televisão | |
* | |
* @param volume parametro do volume | |
*/ | |
@Override | |
public void aumentaVolume(int volume) { | |
if (this.volume != 10) { | |
this.volume = volume + 1; | |
} else { | |
this.volume = 10; | |
} | |
} | |
/** | |
* Diminui o volume da televisão | |
* | |
* @param volume parametro do volume | |
*/ | |
@Override | |
public void diminuiVolume(int volume) { | |
if (this.volume != 10) { | |
this.volume = volume + 1; | |
} else { | |
this.volume = 10; | |
} | |
} | |
/** | |
* Muda o canal da televisão | |
* | |
* @param canal parametro do canaol | |
*/ | |
@Override | |
public void mudaCanal(int canal) { | |
this.canal = canal; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment