Tugas Remote AC
Nama: Donny Fitrado
NRP: 05111740000171
Kelas: PBO A
Di tugas ini saya membuat sebuah remote AC menggunakan BlueJ dengan 2 class, yaitu class "Remote AC" dan Main untuk menjalankan programnya..
2. IntMain
Berikut ini adalah screenshot ketika remote AC dijalankan
1. Tampilan program remote AC setelah memasukkan temperatur (20) pertama kali:
2. Tampilan program remote AC saat memilih opsi 1, yaitu temperatur
3. Tampilan program remote AC setelah memilih untuk menaikkan temperatur menjadi 21 C.
4. Tampilan program remote AC saat memilih opsi 2, yaitu Fan Speed.
5. Tampilan program remote AC setelah menaikkan Fan Speed.
6. Tampilan program remote AC saat memilih opsi 5, yaitu timer untuk mematikan remote AC
Sekian, terima kasih dan mohon maaf apabila ada kesalahan.
NRP: 05111740000171
Kelas: PBO A
Di tugas ini saya membuat sebuah remote AC menggunakan BlueJ dengan 2 class, yaitu class "Remote AC" dan Main untuk menjalankan programnya..
/**
* Membuat RemoteAC AC
* Donny Fitrado
* 05111740000171
* 17-9-18
*/
public class RemoteAC
{
public int temperature;
public int mode;
public int fanspd;
public RemoteAC(int initialtemp)
{
temperature = initialtemp;
mode = 1;
fanspd = 1;
}
public void ACmode(int currentmode)
{
if(currentmode==1)
{
System.out.println("Current Mode : Automatic");
}
else if(currentmode==2)
{
System.out.println("Current Mode : Cold");
}
else if(currentmode==3)
{
System.out.println("Current Mode: Dry");
}
}
public void Mode(int currentmode)
{
ACmode(currentmode);
System.out.println("Input Command to change mode :");
System.out.println("1. Automatic");
System.out.println("2. Cold");
System.out.println("3. Dry");
}
public int ChangeMode(int chosenMode)
{
if(chosenMode == 1)
{
mode = chosenMode;
System.out.println("Current Mode : Automatic");
}
else if(chosenMode == 2)
{
mode = chosenMode;
System.out.println("Current Mode : Cold");
}
else if(chosenMode == 3)
{
mode = chosenMode;
System.out.println("Current Mode : Dry");
}
return(mode);
}
public void temperatures(int currentTemp)
{
System.out.println("Current Temperature :"+currentTemp);
System.out.println("1. Up");
System.out.println("2. Down");
}
public int temperatureUp(int up)
{
up++;
return(up);
}
public int temperatureDown(int down)
{
down--;
return(down);
}
public void fanSpeed(int currentSpeed)
{
if(currentSpeed==1)
{
System.out.println("Currrent Speed : 1");
}
else if(currentSpeed==2)
{
System.out.println("Currrent Speed : 2");
}
else if(currentSpeed==3)
{
System.out.println("Currrent Speed : 3");
}
else if(currentSpeed==4)
{
System.out.println("Currrent Speed : Automatic");
}
}
public void FanMode(int speed)
{
fanSpeed(speed);
System.out.println("Input Command to change mode :");
System.out.println("1. Fan Speed 1");
System.out.println("2. Fan Speed 2");
System.out.println("3. Fan Speed 3");
System.out.println("4. Fan Speed Automatic");
}
public int ACFanSpeed(int nextspeed)
{
if(nextspeed == 1)
{
mode = nextspeed;
System.out.println("Current Fan Speed : "+nextspeed);
}
else if(nextspeed == 2)
{
mode = nextspeed;
System.out.println("Current Fan Speed : "+nextspeed);
}
else if(nextspeed == 3)
{
mode = nextspeed;
System.out.println("Current Fan Speed : "+nextspeed);
}
else if(nextspeed == 4)
{
mode = nextspeed;
System.out.println("Current Fan Speed : Automatic");
}
return(mode);
}
}
2. IntMain
/**
* Ini Main nya
* Donny Fitrado
* 05111740000171
* 17-9-18
*/
import java.util.Scanner;
public class IntMain
{
public static void main()
{
System.out.println("Smart AC is ON");
System.out.println("Enter Temperature :");
Scanner scan= new Scanner(System.in);
int initialtemp;
int temp,modevalue,fan;
int tempTemp,smntr,modeAC,smntr1;
int menu;
int FanSpd,count,i;
boolean status = false;
initialtemp = scan.nextInt();
RemoteAC remAC=new RemoteAC(initialtemp);
modeAC = remAC.mode;
FanSpd = remAC.fanspd;
while(status!=true)
{
System.out.println("==============================");
System.out.println("-------Donny's AC Remote------");
System.out.println("==============================");
System.out.println("Tempratur : "+initialtemp+" °C");
remAC.ACmode(modeAC);
remAC.fanSpeed(FanSpd);
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. Timer");
System.out.println("5. Turn Off AC");
System.out.println("==============================");
menu = scan.nextInt();
System.out.print('\u000C');
if(menu==1)
{
System.out.println("==============================");
System.out.println("-------Donny's AC Remote------");
System.out.println("==============================");
System.out.println("Tempratur : "+initialtemp+ " °C");
remAC.ACmode(modeAC);
remAC.fanSpeed(FanSpd);
System.out.println("==============================");
System.out.println("==============================");
remAC.temperatures(initialtemp);
System.out.println("==============================");
temp = scan.nextInt();
System.out.print('\u000C');
if(temp==1)
{
tempTemp = remAC.temperatureUp(initialtemp);
initialtemp = tempTemp;
}
else if(temp==2)
{
tempTemp = remAC.temperatureDown(initialtemp);
initialtemp = tempTemp;
}
System.out.print('\u000C');
}
else if(menu==2)
{
System.out.println("==============================");
System.out.println("-------Donny's AC Remote------");
System.out.println("==============================");
System.out.println("Tempratur : "+initialtemp+" °C");
remAC.ACmode(modeAC);
remAC.fanSpeed(FanSpd);
System.out.println("==============================");
System.out.println("==============================");
remAC.Mode(modeAC);
System.out.println("==============================");
modevalue = scan.nextInt();
smntr=remAC.ChangeMode(modevalue);
modeAC = smntr;
System.out.print('\u000C');
}
else if(menu==3)
{
System.out.println("==============================");
System.out.println("-------Donny's AC Remote------");
System.out.println("==============================");
System.out.println("Tempratur : "+initialtemp+" °C");
remAC.ACmode(modeAC);
remAC.fanSpeed(FanSpd);
System.out.println("==============================");
System.out.println("==============================");
remAC.FanMode(FanSpd);
System.out.println("==============================");
fan = scan.nextInt();
smntr1 = remAC.ACFanSpeed(fan);
FanSpd = smntr1;
System.out.print('\u000C');
}
else if(menu==4)
{
System.out.print('\u000C');
System.out.print("Enter timer(in seconds)");
count = scan.nextInt();
System.out.println("==============================");
System.out.println(".......Turning AC Off in......");
System.out.println("==============================");
for(i = count; i >=0 ;i--)
{
System.out.print( i+"\n");
}
System.out.println("==========Goodbye :)==========");
status = true;
}
else if(menu==5)
{
System.out.print('\u000C');
status = true;
}
}
}
}
Berikut ini adalah screenshot ketika remote AC dijalankan
1. Tampilan program remote AC setelah memasukkan temperatur (20) pertama kali:
2. Tampilan program remote AC saat memilih opsi 1, yaitu temperatur
3. Tampilan program remote AC setelah memilih untuk menaikkan temperatur menjadi 21 C.
4. Tampilan program remote AC saat memilih opsi 2, yaitu Fan Speed.
5. Tampilan program remote AC setelah menaikkan Fan Speed.
6. Tampilan program remote AC saat memilih opsi 5, yaitu timer untuk mematikan remote AC
Sekian, terima kasih dan mohon maaf apabila ada kesalahan.
Comments
Post a Comment