shouldz

ControleRemotoPOO(02-BluePrint)

Oct 19th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.42 KB | None | 0 0
  1. package Controle_Remoto_V2;
  2.  
  3. public class ControleBluePrint implements ControleInterface {
  4.     private int volume;
  5.     private boolean ligado;
  6.     private boolean tocando;
  7.     private int canal;
  8.     private int pilha;
  9.     private int casomudoOn;
  10.  
  11.     private void setVolume(int volume) {
  12.         this.volume = volume;
  13.         this.casomudoOn = getVolume();
  14.     }
  15.  
  16.     public int getVolume(){
  17.         return this.volume;
  18.     }
  19.  
  20.     private void setTocando(boolean tocando) {
  21.         this.tocando = tocando;
  22.     }
  23.  
  24.     public boolean getTocando(){
  25.         return this.tocando;
  26.     }
  27.  
  28.     private void setLigado(boolean ligado) {
  29.         this.ligado = ligado;
  30.     }
  31.  
  32.     public boolean getLigado() {
  33.         return this.ligado;
  34.     }
  35.  
  36.     private void setCanal(int canal) {
  37.         this.canal = canal;
  38.     }
  39.  
  40.     public int getCanal() {
  41.         return this.canal;
  42.     }
  43.  
  44.     public void setPilha(int pilha){
  45.         this.pilha = pilha;
  46.     }
  47.  
  48.     public void trocarPilha(int pilha){
  49.         this.pilha = pilha * 1000;
  50.     }
  51.  
  52.     public int getPilha(){
  53.         return this.pilha;
  54.     }
  55.  
  56.     public ControleBluePrint(){
  57.         this.setVolume(30);
  58.         this.setCanal(1);
  59.         this.setLigado(false);
  60.         this.setTocando(false);
  61.         this.setPilha(0);
  62.     }
  63.  
  64.  
  65.     @Override
  66.     public void ligar() {
  67.         if(!this.getLigado() && this.getPilha() >= 1){
  68.             this.setLigado(true);
  69.             this.setPilha(getPilha() - 1);
  70.         }else if(this.getPilha() < 1){
  71.             System.out.println("Error: Trocar Pilha");
  72.         }
  73.     }
  74.  
  75.     @Override
  76.     public void desligar() {
  77.         if(this.getLigado() && this.getPilha() >= 1){
  78.             System.out.println("Desligado");
  79.             this.setLigado(false);
  80.             this.setPilha(getPilha() - 1);
  81.         }else if(this.getPilha() < 1){
  82.             System.out.println("Error: Trocar Pilha");
  83.         }
  84.     }
  85.  
  86.     @Override
  87.     public void maisVolume() {
  88.         if (this.getLigado() && this.getPilha() >= 1) {
  89.             if (this.getVolume() < 100) {
  90.                 this.setVolume(this.getVolume() + 5);
  91.                 this.setPilha(getPilha() - 1);
  92.             }else if(this.getPilha() < 1){
  93.                 System.out.println("Error: Trocar Pilha");
  94.             }
  95.             if (this.getVolume() == 100) {
  96.                 System.out.println("Vol Max.");
  97.                 this.setPilha(getPilha() - 1);
  98.             }else if(this.getPilha() < 1){
  99.                 System.out.println("Error: Trocar Pilha");
  100.             }
  101.         }
  102.     }
  103.  
  104.     @Override
  105.     public void menosVolume() {
  106.         if(this.getLigado() && this.getPilha() >= 1) {
  107.             if (this.getVolume() > 0) {
  108.                 this.setVolume(this.getVolume() - 5);
  109.                 this.setPilha(getPilha() - 1);
  110.             }else if(this.getPilha() < 1){
  111.                 System.out.println("Error: Trocar Pilha");
  112.             }
  113.             if (this.getVolume() == 0) {
  114.                 System.out.println("Vol Min.");
  115.                 this.setPilha(getPilha() - 1);
  116.             }else if(this.getPilha() < 1){
  117.                 System.out.println("Error: Trocar Pilha");
  118.             }
  119.         }
  120.     }
  121.  
  122.     @Override
  123.     public void abrirMenu() {
  124.         if(this.getLigado() && this.getPilha() >= 1){
  125.             this.setPilha(getPilha() - 1);
  126.             System.out.println("=====MENU=====");
  127.             System.out.println("Ligado: " + this.getLigado());
  128.             System.out.println("Tocando: " + this.getTocando());
  129.             System.out.println("Volume: " + this.getVolume());
  130.             System.out.println("Canal atual: " + this.getCanal());
  131.             System.out.println("Nivel da Pilha " + this.getPilha());
  132.         }else if(this.getLigado() && this.getPilha() < 1){
  133.             System.out.println("Error: Trocar Pilha");
  134.         }
  135.     }
  136.  
  137.     @Override
  138.     public void fecharMenu() {
  139.         if(getLigado() && this.getPilha() >= 1) {
  140.             System.out.println("Fechando Menu ...");
  141.             this.setPilha(this.getPilha() - 1);
  142.         }
  143.         if(this.getPilha() < 1){
  144.             System.out.println("Error: Trocar Pilha");
  145.         }
  146.     }
  147.  
  148.     @Override
  149.     public void canalAcima() {
  150.         if(this.getLigado() && this.getPilha() >= 1){
  151.             if(getCanal() < 100){
  152.                 this.setCanal(this.getCanal() + 1);
  153.                 this.setPilha(getPilha() - 1);
  154.             }
  155.         }else if(this.getPilha() < 1){
  156.             System.out.println("Error: Trocar Pilha");
  157.         }
  158.     }
  159.  
  160.     @Override
  161.     public void canalAbaixo() {
  162.         if(this.getLigado() && this.getPilha() >= 1){
  163.             if(getCanal() > 2){
  164.                 this.setCanal(this.getCanal() - 1);
  165.                 this.setPilha(getPilha() - 1);
  166.             }
  167.         }else if(this.getPilha() < 1){
  168.             System.out.println("Error: Trocar Pilha");
  169.         }
  170.     }
  171.  
  172.     @Override
  173.     public void play() {
  174.         if(this.getLigado() && this.getPilha() >= 1){
  175.             this.setTocando(true);
  176.             this.setPilha(getPilha() - 1);
  177.         }else if(this.getPilha() < 1){
  178.             System.out.println("Error: Trocar Pilha");
  179.         }
  180.     }
  181.  
  182.     @Override
  183.     public void pause() {
  184.         if(this.getLigado() && this.getPilha() >= 1){
  185.             this.setTocando(false);
  186.             this.setPilha(getPilha() - 1);
  187.         }else if(this.getPilha() < 1){
  188.             System.out.println("Error: Trocar Pilha");
  189.         }
  190.     }
  191.  
  192.     @Override
  193.     public void mudoOff() {
  194.         int casomudoOn;
  195.         if(this.getLigado() && this.getPilha() >= 1){
  196.             this.setVolume(0);
  197.             this.setPilha(getPilha() - 1);
  198.         }else if(this.getPilha() < 1){
  199.             System.out.println("Error: Trocar Pilha");
  200.         }
  201.     }
  202.  
  203.     @Override
  204.     public void mudoOn() {
  205.         if(this.getLigado() && this.getPilha() >= 1){
  206.             this.setVolume(this.casomudoOn);
  207.             this.setPilha(getPilha() - 1);
  208.         }else if(this.getPilha() < 1){
  209.             System.out.println("Error: Trocar Pilha");
  210.         }
  211.     }
  212.  
  213.     @Override
  214.     public void selecionarCanal(int canalnumber) {
  215.         if(getLigado() && this.getPilha() >= 1 && canalnumber <= 100){
  216.             this.setCanal(canalnumber);
  217.         }else if(this.getPilha() < 1){
  218.             System.out.println("Error: Trocar Pilha");
  219.         }else if(canalnumber > 100){
  220.             System.out.println("Canal invalido!");
  221.         }
  222.     }
  223. }
Advertisement
Add Comment
Please, Sign In to add comment