Rancangan remote AC yang saya buat menyediakan 4 menu.
Berikut saya sertakan codingan remoteAC saya:
Tampilan pada saat awal program dinyalakan
- Naik turun temperatur
- Mode Fan AC
- Kecepatan Kipas AC
- Mematikan AC
Berikut saya sertakan codingan remoteAC saya:
/**
* Program Remote AC.
*
* @author Bobbi Aditya
* @version 1.0
*/
public class RemoteAC
{
public int temp;
public int mode;
public boolean power;
public int kipas;
public RemoteAC(int tempawal)
{
temp = tempawal;
mode = 1;
power = true;
kipas = 1;
}
public void modeAC(int modeskrg)
{
if(modeskrg==1)
{
System.out.print("Otomatis");
}
else if(modeskrg==2)
{
System.out.print("Dingin");
}
else if(modeskrg==3)
{
System.out.print("Kering");
}
else if(modeskrg==4)
{
System.out.print("Kipas");
}
else if(modeskrg==5)
{
System.out.print("Panas");
}
}
public void Mode(int modeskrg)
{
System.out.println("Masukkan angka untuk mengganti mode :");
System.out.println("1. Otomatis");
System.out.println("2. Dingin");
System.out.println("3. Kering");
System.out.println("4. Kipas");
System.out.println("5. Panas");
}
public int gantiMode(int modePilihan)
{
if(modePilihan == 1)
{
mode = modePilihan;
System.out.println("Mode berhasil diubah. Mode sekarang : Otomatis");
}
else if(modePilihan == 2)
{
mode = modePilihan;
System.out.println("Mode berhasil diubah. Mode sekarang : Dingin");
}
else if(modePilihan == 3)
{
mode = modePilihan;
System.out.println("Mode berhasil diubah. Mode sekarang : Kering");
}
else if(modePilihan == 4)
{
mode = modePilihan;
System.out.println("Mode berhasil diubah. Mode sekarang : Kipas");
}
else if(modePilihan == 5)
{
mode = modePilihan;
System.out.println("Mode berhasil diubah. Mode sekarang : Panas");
}
return(mode);
}
public void tempratur(int tempskrg)
{
System.out.println("Tempratur Sekarang :"+tempskrg);
System.out.println("1. Naik");
System.out.println("2. Turun");
}
public int tempraturNaik(int naik)
{
if(naik>=27)
{
}
else
{
naik++;
}
return(naik);
}
public int tempraturTurun(int turun)
{
if(turun<=16)
{
}
else
{
turun--;
}
return(turun);
}
public void kecKipas(int kecskrg)
{
if(kecskrg==1)
{
System.out.println("Kecepatan sekarang: 1");
}
else if(kecskrg==2)
{
System.out.println("Kecepatan sekarang: 2");
}
else if(kecskrg==3)
{
System.out.println("Kecepatan sekarang: 3");
}
else if(kecskrg==4)
{
System.out.println("Kecepatan sekarang: Otomatis");
}
}
public void Kipas(int kecskrg)
{
kecKipas(kecskrg);
System.out.println("Masukkan angka untuk mengganti mode :");
System.out.println("1. Kecepatan 1");
System.out.println("2. Kecepatan 2");
System.out.println("3. Kecepatan 3");
System.out.println("4. Kecepatan 4");
}
public int kecepatanKipas(int kecepatan)
{
if(kecepatan == 1)
{
mode = kecepatan;
System.out.println("Kecepatan kipas berhasil diubah. Sekarang : Kecepatan "+kecepatan);
}
else if(kecepatan == 2)
{
mode = kecepatan;
System.out.println("Kecepatan kipas berhasil diubah. Sekarang : Kecepatan "+kecepatan);
}
else if(kecepatan == 3)
{
mode = kecepatan;
System.out.println("Kecepatan kipas berhasil diubah. Sekarang : Kecepatan "+kecepatan);
}
else if(kecepatan == 4)
{
mode = kecepatan;
System.out.println("Kecepatan kipas berhasil diubah. Sekarang : Kecepatan "+kecepatan);
}
return(mode);
}
}
Berikut saya sertakan kodingan main saya /**
* Write a description of class main here.
*
* @author Bobbi Aditya
* @version 1.0
*/
import java.util.Scanner;
public class IntMain
{
public static void main(String args[])
{
System.out.print('\u000C');
System.out.println("AC berhasil dinyalakan.");
System.out.println("Masukkan tempratur awal (16 derajat-27 derajat) :");
Scanner scan= new Scanner(System.in);
int tempDasar;
int nilaitemp,nilaimode,nilaikipas;
int sementara,smntr,modeAC,smntr1;
int menu;
int KecKipas;
boolean cek;
tempDasar = scan.nextInt();
if(tempDasar>=16 && tempDasar<=27)
{
RemoteAC remAC=new RemoteAC(tempDasar);
modeAC = remAC.mode;
KecKipas = remAC.kipas;
while(true)
{
System.out.print('\u000C');
System.out.println("------------------------------------");
System.out.println("-----------Remote AC Bobbi----------");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("-----"+tempDasar+" derajat-------Fan Speed "+KecKipas+"----");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.print("-------------mode ");remAC.modeAC(modeAC);System.out.println("----------");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("------------------------------------");
System.out.println("Menu");
System.out.println("1. Ubah Tempratur");
System.out.println("2. Ubah Mode");
System.out.println("3. Ubah Kecepatan Kipas");
System.out.println("4. Matikan AC");
System.out.println("------------------------------------");
menu = scan.nextInt();
System.out.print('\u000C');
if(menu==1)
{
System.out.println("------------------------------------");
System.out.println("-----------Remote AC Bobbi----------");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("-----"+tempDasar+" derajat-------Fan Speed "+KecKipas+"----");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.print("-------------mode ");remAC.modeAC(modeAC);System.out.println("----------");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("------------------------------------");
remAC.tempratur(tempDasar);
System.out.println("++++++++++++++++++++++++++++++++++++");
nilaitemp = scan.nextInt();
if(nilaitemp==1)
{
sementara = remAC.tempraturNaik(tempDasar);
tempDasar = sementara;
}
else if(nilaitemp==2)
{
sementara = remAC.tempraturTurun(tempDasar);
tempDasar = sementara;
}
System.out.print('\u000C');
}
else if(menu==2)
{
System.out.println("------------------------------------");
System.out.println("-----------Remote AC Bobbi----------");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("-----"+tempDasar+" derajat-------Fan Speed "+KecKipas+"----");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.print("-------------mode ");remAC.modeAC(modeAC);System.out.println("----------");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("------------------------------------");
remAC.Mode(modeAC);
System.out.println("++++++++++++++++++++++++++++++++++++");
nilaimode = scan.nextInt();
smntr=remAC.gantiMode(nilaimode);
modeAC = smntr;
System.out.print('\u000C');
}
else if(menu==3)
{
System.out.println("------------------------------------");
System.out.println("-----------Remote AC Bobbi----------");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("-----"+tempDasar+" derajat-------Fan Speed "+KecKipas+"----");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.print("-------------mode ");remAC.modeAC(modeAC);System.out.println("----------");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("------------------------------------");
remAC.Kipas(KecKipas);
System.out.println("++++++++++++++++++++++++++++++++++++");
nilaikipas = scan.nextInt();
smntr1 = remAC.kecepatanKipas(nilaikipas);
KecKipas = smntr1;
System.out.print('\u000C');
}
else if(menu==4)
{
System.out.print('\u000C');
break;
}
}
}
else
{
System.out.println("Temperatur AC hanya bisa dari 16-28");
}
}
}
Berikut hasilnya:Tampilan pada saat awal program dinyalakan
Tampilan setelah input temperatur awal
Tampilan setelah menginput menu 1
Tampilan setelah menekan menu ubah mode
Tampilan setelah menekan menu ubah kecepatan kipas
Hasil akhir setelah melakukan hal - hal diatas
Nama : Bobbi Aditya
Kelas : PBO A
NRP : 05111740000099
Comments
Post a Comment