Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Controle_Remoto_V2;
- public class ControleBluePrint implements ControleInterface {
- private int volume;
- private boolean ligado;
- private boolean tocando;
- private int canal;
- private int pilha;
- private int casomudoOn;
- private void setVolume(int volume) {
- this.volume = volume;
- this.casomudoOn = getVolume();
- }
- public int getVolume(){
- return this.volume;
- }
- private void setTocando(boolean tocando) {
- this.tocando = tocando;
- }
- public boolean getTocando(){
- return this.tocando;
- }
- private void setLigado(boolean ligado) {
- this.ligado = ligado;
- }
- public boolean getLigado() {
- return this.ligado;
- }
- private void setCanal(int canal) {
- this.canal = canal;
- }
- public int getCanal() {
- return this.canal;
- }
- public void setPilha(int pilha){
- this.pilha = pilha;
- }
- public void trocarPilha(int pilha){
- this.pilha = pilha * 1000;
- }
- public int getPilha(){
- return this.pilha;
- }
- public ControleBluePrint(){
- this.setVolume(30);
- this.setCanal(1);
- this.setLigado(false);
- this.setTocando(false);
- this.setPilha(0);
- }
- @Override
- public void ligar() {
- if(!this.getLigado() && this.getPilha() >= 1){
- this.setLigado(true);
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void desligar() {
- if(this.getLigado() && this.getPilha() >= 1){
- System.out.println("Desligado");
- this.setLigado(false);
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void maisVolume() {
- if (this.getLigado() && this.getPilha() >= 1) {
- if (this.getVolume() < 100) {
- this.setVolume(this.getVolume() + 5);
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- if (this.getVolume() == 100) {
- System.out.println("Vol Max.");
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- }
- @Override
- public void menosVolume() {
- if(this.getLigado() && this.getPilha() >= 1) {
- if (this.getVolume() > 0) {
- this.setVolume(this.getVolume() - 5);
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- if (this.getVolume() == 0) {
- System.out.println("Vol Min.");
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- }
- @Override
- public void abrirMenu() {
- if(this.getLigado() && this.getPilha() >= 1){
- this.setPilha(getPilha() - 1);
- System.out.println("=====MENU=====");
- System.out.println("Ligado: " + this.getLigado());
- System.out.println("Tocando: " + this.getTocando());
- System.out.println("Volume: " + this.getVolume());
- System.out.println("Canal atual: " + this.getCanal());
- System.out.println("Nivel da Pilha " + this.getPilha());
- }else if(this.getLigado() && this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void fecharMenu() {
- if(getLigado() && this.getPilha() >= 1) {
- System.out.println("Fechando Menu ...");
- this.setPilha(this.getPilha() - 1);
- }
- if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void canalAcima() {
- if(this.getLigado() && this.getPilha() >= 1){
- if(getCanal() < 100){
- this.setCanal(this.getCanal() + 1);
- this.setPilha(getPilha() - 1);
- }
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void canalAbaixo() {
- if(this.getLigado() && this.getPilha() >= 1){
- if(getCanal() > 2){
- this.setCanal(this.getCanal() - 1);
- this.setPilha(getPilha() - 1);
- }
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void play() {
- if(this.getLigado() && this.getPilha() >= 1){
- this.setTocando(true);
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void pause() {
- if(this.getLigado() && this.getPilha() >= 1){
- this.setTocando(false);
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void mudoOff() {
- int casomudoOn;
- if(this.getLigado() && this.getPilha() >= 1){
- this.setVolume(0);
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void mudoOn() {
- if(this.getLigado() && this.getPilha() >= 1){
- this.setVolume(this.casomudoOn);
- this.setPilha(getPilha() - 1);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }
- }
- @Override
- public void selecionarCanal(int canalnumber) {
- if(getLigado() && this.getPilha() >= 1 && canalnumber <= 100){
- this.setCanal(canalnumber);
- }else if(this.getPilha() < 1){
- System.out.println("Error: Trocar Pilha");
- }else if(canalnumber > 100){
- System.out.println("Canal invalido!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment