Minggu, 23 September 2018

PBO A- REMOTE AC

Nama: Ayu Mutiara Sari
NRP: 05111740000149
Kelas:PBO A

Berikut ini adalah fungsi-fungsi yang ada di remote AC saya:
1. Fungsi untu menyala dan mematikan remote AC
2. Fungsi untuk mengatur suhu dan menampilkan suhu
3. Fungsi untuk mengatur mode AC dan menampilkan mode AC
4. Fungsi untuk mengatur fungsi swing AC

Saya menggunakan 2 class yaitu class main dan display:

Berikut Source codenya:

1. Main
 /**  
  * Write a description of class Main here.  
  * AC  
  * @author (ayu mutiara sari)  
  * @version (20.01)  
  */  
 import java.util.Scanner;    
  public class Main   
  {   
   public static void main(String args[])   
   {   
    {   
     Scanner scan= new Scanner(System.in);    
     int on, pilihan, mode, swing;   
     String mod;   
     System.out.println();   
     System.out.println("PANASONIC AIR CONDITIONER");   
     System.out.println("PRESS 0 TO TURN ON");   
     Display remote = new Display ();   
     on = scan.nextInt();   
     while(true){   
     if (on==0){   
      remote.print();   
     while (true){   
     pilihan = scan.nextInt();   
     switch (pilihan)   
     {   
     case 0:   
     System.out.println("TURNED OFF");   
     System.exit(0);   
     break;   
     case 1:   
     remote.TempUp();   
     remote.print();   
     break;   
     case 2:   
     remote.TempDown();   
     remote.print();   
     break;   
     case 3:   
     System.out.println("1. COOL");   
     System.out.println("2. HEAT");   
     System.out.println("3. AUTO");   
     System.out.println("4. DRY");   
     System.out.println("5. FAN");   
     mode=scan.nextInt();   
     if(mode<1 || mode>5){   
      System.out.println("ERROR.\n");   
      }   
     else{   
     mod= remote.getMode(mode);   
     }   
     remote.print();   
     break;   
     case 4:   
     remote.getSwing();   
     remote.print();   
     break;   
     }   
    }   
   }   
    else {   
    System.out.println("ERROR.");   
    on = scan.nextInt();   
     }   
    }   
   }   
  }   
  }   

2. Display
 /**  
  * Write a description of class display here.  
  *  
  * @author (ayu mutiara sari)  
  * @version (20.01)  
  */  
 public class Display   
  {   
   private int Temp;   
   private int nyala;   
   private int TempDef;   
   private int mode;   
   private String Mode, Swing;   
   private boolean isSwing;   
   /**   
   * Constructor for objects of class RemoteAC   
   */   
   public Display()   
   {   
    TempDef = 20;   
    Mode = new String("AUTO");   
    Swing = new String("OFF");   
    isSwing = false;   
   }   
   public int TempUp(){   
    if(TempDef==30){   
     System.out.println("--   INVALID   --");   
     System.out.println("-----------------------------------------");}   
     else{   
    TempDef++;}   
    return TempDef;   
   }   
   public int TempDown(){   
    if(TempDef==16){   
     System.out.println("--   INVALID   --");   
     System.out.println("-----------------------------------------");}   
     else{   
    TempDef--;}   
    return TempDef;   
   }   
   public String getMode(int mode){   
    if(mode==1){   
     Mode = new String ("COOL");   
    }   
    else if(mode==2){   
     Mode = new String ("HEAT");   
    }   
    else if(mode==3){   
     Mode = new String ("AUT)");   
    }   
    else if(mode==4){   
     Mode = new String ("DRY");   
    }   
    else if(mode ==5){   
     Mode = new String ("FAN");   
    }   
    else{   
     Mode = new String ("ERROR");   
  }   
   return Mode;}   
   public String getSwing(){   
    if (isSwing==false){   
     isSwing=true;   
     Swing=new String("ON");}   
    else {   
     isSwing=false;   
     Swing=new String("OFF");}   
     return Swing;   
    }   
   public void print(){   
    System.out.println("_____________________");   
    System.out.println("||  PANASONIC  ||");   
    System.out.println("|| AIR CONDITIONER ||");   
    System.out.println("||  "+TempDef+" CELCIUS  ||");   
    System.out.println("||  MODE = "+Mode+"  ||");   
    System.out.println("||  SWING = "+Swing+"  ||");   
    System.out.println("||-----------------||");   
    System.out.println("|| 1.Temperature ^ ||");   
    System.out.println("|| 2.Temperature v ||");   
    System.out.println("|| 3.Mode     ||");   
    System.out.println("|| 4.Swing Mode  ||");   
    System.out.println("|| 0.Turn Off   ||");   
    System.out.println("||-----------------||");   
    System.out.println("||_________________||");   
    System.out.println();   
  }   
  }   
Hasil:





0 komentar:

Posting Komentar