MEMBUAT REMOTE AC MENGGUKAN JAVA
Nama : Yudhistiro Adi Nugroho
NRP : 05111740000165
Kelas : PBO A
Gambar 1. Tampilan Awal & Suhu
Gambar 2. Menaikkan Suhu
Gambar 3. Turunkan Suhu
Gambar 4. Mode AC
Gambar 5. Swing ON/OFF
Gambar 6. Tampilan di Blue-J
/**
* Program Remote AC.
*
* @author (Yudhistiro Adi Nugroho)
* @version (9.19.2018)
*/
import java.util.Scanner;
public class IntMain
{
public static void main(String[]args){
Scanner scan = new Scanner(System.in);
int Temp,menu,menu2;
String simpan = " ";
simpan = "Cool";
String tmp="OFF";
System.out.println("Input Angka 1 untuk mengaktifkan AC\n");
Temp=scan.nextInt();
while(true)
{
if(Temp==1)
{
RemoteAc remote=new RemoteAc(Temp);
System.out.println("||SELAMAT DATANG||");
System.out.println("|| AC SAMSUNG ||");
while(true)
{
System.out.println("1. Temperature Sekarang");
System.out.println("2. Off");
System.out.println("3. Naikkan Suhu (+)");
System.out.println("4. Turunkan Suhu (-)");
System.out.println("5. Mode");
System.out.println("6. Swing");
menu=scan.nextInt();
switch(menu)
{
case 1:
System.out.println("......................");
System.out.println("Temperature = "+remote.getBalance0()+"°c");
System.out.println(" Mode = "+simpan);
System.out.println(" Swing = "+tmp);
System.out.println("......................");
break;
case 2:
System.out.println("~Sampai Jumpa Kembali~");
return;
case 3:
System.out.println("......................");
System.out.println("Temperature = "+remote.getBalance()+"°c");
System.out.println(" Mode = "+simpan);
System.out.println(" Swing = "+tmp);
System.out.println("......................");
break;
case 4:
System.out.println("......................");
System.out.println("Temperature = "+remote.getBalance2()+"°c");
System.out.println(" Mode = "+simpan);
System.out.println(" Swing = "+tmp);
System.out.println("......................");
break;
case 5:
System.out.println("==================");
System.out.println(" 1. Cool");
System.out.println(" 2. Dry");
System.out.println(" 3. Fan");
System.out.println(" 4. Heat");
System.out.println("==================");
menu2= scan.nextInt();
if(menu2==1){
simpan = "Cool";
System.out.println("......................");
System.out.println("Temperature = "+remote.getBalance0()+"°c");
System.out.println(" Mode = "+simpan);
System.out.println(" Swing = "+tmp);
System.out.println("......................");
}
if(menu2==2){
simpan = "Dry";
System.out.println("......................");
System.out.println("Temperature = "+remote.getBalance0()+"°c");
System.out.println(" Mode = "+simpan);
System.out.println(" Swing = "+tmp);
System.out.println("......................");
}
if(menu2==3){
simpan = "Fan";
System.out.println("......................");
System.out.println("Temperature = "+remote.getBalance0()+"°c");
System.out.println(" Mode = "+simpan);
System.out.println(" Swing = "+tmp);
System.out.println("......................");
}
if(menu2==4){
simpan = "Heat";
System.out.println("......................");
System.out.println("Temperature = "+remote.getBalance0()+"°c");
System.out.println(" Mode = "+simpan);
System.out.println(" Swing = "+tmp);
System.out.println("......................");
}
break;
case 6:
if(tmp == "OFF"){
System.out.println("......................");
System.out.println("Temperature = "+remote.getBalance0()+"°c");
System.out.println(" Mode = "+simpan);
System.out.println(" Swing = ON");
System.out.println("......................");
tmp= "ON";
}
else if(tmp == "ON"){
System.out.println("......................");
System.out.println("Temperature = "+remote.getBalance0()+"°c");
System.out.println(" Mode = "+simpan);
System.out.println(" Swing = OFF");
System.out.println("......................");
tmp= "OFF";
}
break;
}
}
}
else{
System.out.println("Input Salah. AC Tidak Menyala");
Temp=scan.nextInt();
}
}
}
}
RemoteAc
/**
* Program Remote AC.
*
* @author (Yudhistiro Adi Nugroho)
* @version (9.19.2018)
*/
public class RemoteAc
{
private int balance;private int Temperature;
public RemoteAc (int remoteTemperature)
{
Temperature= 25;
}
public int getBalance0()
{
return Temperature;
}
public int getBalance()
{
if(Temperature == 33)
{Temperature = 33;
System.out.println(" |Peringatan!|");
System.out.println("|Suhu sudah maksimal|");
return Temperature;}
Temperature++;
return Temperature;
}
public int getBalance2()
{
if(Temperature == 16)
{Temperature = 16;
System.out.println(" |Peringatan!|");
System.out.println("|Suhu sudah minimal|");
return Temperature;}
Temperature--;
return Temperature;
}
}
Comments
Post a Comment