PBO3-Simulasi Membuat Remote AC

Tugas 3 PBO-A
Pada kali ini saya ditugaskan untuk membuat simulasi sebuah remote AC. Sebelum diberi tugas ini kami sudah pernah membuat simulasi mesin tiket. Lalu selanjutnya kami membuat simulasi remote AC dalam BlueJ.
Disini saya menggunakan hanya 2 class yaitu:

  1. IntMain
  2. RemoteAC

  • IntMain

 /**  
  * Main remote AC  
  *  
  * @author Samuel Marcellinus  
  * 05111740000134  
  */  
 import java.util.Scanner;   
  public class IntMain  
  {   
    public static void main(String args[])   
    {  
    System.out.print('\u000C');  
    System.out.println("AC is on!");  
    System.out.println("Insert temperature! :");   
    Scanner scan= new Scanner(System.in);   
    int suhuawal;  
    int nilaitemp,nilaimode,nilaikipas;  
    int temporary,temporary1,modeAC,temporary11;  
    int menu;   
    int fan;  
    boolean cek;  
    suhuawal = scan.nextInt();  
    if(suhuawal >=16 && suhuawal <=27)  
    {  
    RemoteAC remAC=new RemoteAC(suhuawal);  
    modeAC = remAC.mode;  
    fan = remAC.kipas;  
    while(true)  
    {  
      System.out.print('\u000C');  
      System.out.println("|||||||||||||||||||||||||||||||");  
      System.out.println("|||||||         |||||||");  
      System.out.println("|||||||Remote AC SamuelM|||||||");  
      System.out.println("|||||||         |||||||");  
      System.out.println("|||||||||||||||||||||||||||||||");  
      System.out.println("Temperature : "+suhuawal);  
      remAC.modeAC(modeAC);  
      remAC.kecKipas(fan);  
      System.out.println("|||||||||||||||||||||||||||||||");  
      System.out.println("|||||||||||||||||||||||||||||||");  
      System.out.println("Menu");  
      System.out.println("1. Temperature");   
      System.out.println("2. Mode");   
      System.out.println("3. Fan");  
      System.out.println("4. Turn Off");  
      System.out.println("|||||||||||||||||||||||||||||||");  
      System.out.println("|||||||||||||||||||||||||||||||");  
      menu = scan.nextInt();  
      System.out.print('\u000C');  
      if(menu==1)  
      {  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||         |||||||");  
        System.out.println("|||||||Remote AC SamuelM|||||||");  
        System.out.println("|||||||         |||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("Temperature : "+suhuawal);  
        remAC.modeAC(modeAC);  
        remAC.kecKipas(fan);  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        remAC.temperatur(suhuawal);  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        nilaitemp = scan.nextInt();  
        if(nilaitemp==1)  
        {  
          temporary = remAC.temperaturNaik(suhuawal);  
          suhuawal = temporary;  
        }  
        else if(nilaitemp==2)  
        {  
          temporary = remAC.temperaturTurun(suhuawal);  
          suhuawal = temporary;  
        }  
        System.out.print('\u000C');  
      }  
      else if(menu==2)  
      {  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||         |||||||");  
        System.out.println("|||||||Remote AC SamuelM|||||||");  
        System.out.println("|||||||         |||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("Temperature : "+suhuawal);  
        remAC.modeAC(modeAC);  
        remAC.kecKipas(fan);  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        remAC.Mode(modeAC);  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        nilaimode = scan.nextInt();  
        temporary1=remAC.gantiMode(nilaimode);  
        modeAC = temporary1;  
        System.out.print('\u000C');  
      }  
      else if(menu==3)  
      {  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||         |||||||");  
        System.out.println("|||||||Remote AC SamuelM|||||||");  
        System.out.println("|||||||         |||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("Temperature : "+suhuawal);  
        remAC.modeAC(modeAC);  
        remAC.kecKipas(fan);  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        remAC.Kipas(fan);  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        System.out.println("|||||||||||||||||||||||||||||||");  
        nilaikipas = scan.nextInt();  
        temporary11 = remAC.kecepatanKipas(nilaikipas);  
        fan = temporary11;  
        System.out.print('\u000C');  
      }  
      else if(menu==4)  
      {  
        System.out.print('\u000C');  
        break;  
      }  
     }  
     }  
     else{  
       System.out.println("AC tidak berhasil dinyalakan. Suhu AC hanya antara 16-27");  
     }  
   }  
 }  

  • RemoteAC

 /**  
  * Program untuk Remote AC.  
  *  
  * @author Samuel Marcellinus  
  * 05111740000134  
  */  
 public class RemoteAC  
 {  
   public int suhudasar;  
   public int mode;  
   public boolean power;  
   public int kipas;  
   public RemoteAC(int TemperaturAwal)  
   {  
     suhudasar = TemperaturAwal;  
     mode = 1;  
     power = true;  
     kipas = 1;  
   }  
   public void modeAC(int ModeSekarang )  
   {  
     if(ModeSekarang ==1)  
     {  
       System.out.println("Mode : Automatic");  
     }  
     else if(ModeSekarang ==2)  
     {  
       System.out.println("Mode : Cool");  
     }  
     else if(ModeSekarang ==3)  
     {  
       System.out.println("Mode : Dry");  
     }  
     else if(ModeSekarang ==4)  
     {  
       System.out.println("Mode : Heat");  
     }  
   }  
   public void Mode(int ModeSekarang )  
   {  
     modeAC(ModeSekarang );  
     System.out.println("1. Automatic");  
     System.out.println("2. Cool");  
     System.out.println("3. Dry");  
     System.out.println("4. Heat");  
   }  
   public int gantiMode(int modePilihan)  
   {  
     if(modePilihan == 1)  
     {  
       mode = modePilihan;  
       System.out.println("Mode berhasil diubah! Mode : Automatic");  
     }  
     else if(modePilihan == 2)  
     {  
       mode = modePilihan;  
       System.out.println("Mode berhasil diubah! Mode : Cool");  
     }  
     else if(modePilihan == 3)  
     {  
       mode = modePilihan;  
       System.out.println("Mode berhasil diubah! Mode : Dry");  
     }  
     else if(modePilihan == 4)  
     {  
       mode = modePilihan;  
       System.out.println("Mode berhasil diubah! Mode : Heat");  
     }  
     return(mode);  
   }  
   public void temperatur(int tempskrg)  
   {  
     System.out.println("Current Temperature :"+tempskrg);  
     System.out.println("1. Increase");  
     System.out.println("2. Decrease");  
   }  
   public int temperaturNaik(int naik)  
   {  
     if(naik>=27){  
     }  
     else{  
       naik++;  
     }  
     return(naik);  
   }  
   public int temperaturTurun(int turun)  
   {  
     if(turun<=16){  
     }  
     else{  
       turun--;  
     }  
       return(turun);  
   }  
   public void kecKipas(int kecskrg)  
   {  
     if(kecskrg==1)  
     {  
       System.out.println("Fan : Low");  
     }  
     else if(kecskrg==2)  
     {  
       System.out.println("Fan : Medium");  
     }  
     else if(kecskrg==3)  
     {  
       System.out.println("Fan : High");  
     }  
     else if(kecskrg==4)  
     {  
       System.out.println("Fan : Automatic");  
     }  
   }  
   public void Kipas(int kecskrg)  
   {  
     kecKipas(kecskrg);  
     System.out.println("1. Low");  
     System.out.println("2. Med");  
     System.out.println("3. High");  
     System.out.println("4. Automatic");  
   }  
   public int kecepatanKipas(int kecepatan)  
   {  
     if(kecepatan == 1)  
     {  
       mode = kecepatan;  
       System.out.println("Fan changed! Now : "+kecepatan);  
     }  
     else if(kecepatan == 2)  
     {  
       mode = kecepatan;  
       System.out.println("Fan changed! Now :  "+kecepatan);  
     }  
     else if(kecepatan == 3)  
     {  
       mode = kecepatan;  
       System.out.println("Fan changed! Now :  "+kecepatan);  
     }  
     else if(kecepatan == 4)  
     {  
       mode = kecepatan;  
       System.out.println("Fan changed! Now :  Automatic");  
     }  
     return(mode);  
   }  
 }  

Tampilan awal AC : 


Saya memasukkan suhu 18 derajat disini :


Untuk menaikkan suhu :


Hasil menaikkan suhu :


Untuk mengganti mode AC :


Hasil mengganti mode AC :


Untuk mengganti Fan :


Hasil mengganti Fan AC :


Hasil saat di turn off :





Comments

Popular posts from this blog

APSI 1 - Analisa Sistem Informasi Lazada

Tugas 3 PBKK