Pada postingan kali ini saya akan mempost mengenai tugas PBO A yaitu membuat program yang menggambarakan sistem remote AC.
Class Main:
Class RemoteAC:
Class Main:
import java.util.Scanner;
public class Main
{
public static void Main(){
Scanner scan= new Scanner(System.in);
int menu;
RemoteAC RA = new RemoteAC();
int temp = RA.Temp;
int mstat = RA.modeStat;
boolean pow = RA.Power;
while(pow!=false){
System.out.println(".........'Remote AC Rusak'.........");
System.out.println("----------------------------------");
RA.powerStat(pow);
RA.tempStat(temp);
RA.modeAC(mstat);
System.out.println("----------------------------------");
System.out.println("Menu");
System.out.println("1. Turn ON/OFF");
System.out.println("2. Temperature");
System.out.println("3. Mode");
System.out.println("----------------------------------");
menu = scan.nextInt();
System.out.print('\u000C');//clear screen
if(menu==1){//power
pow = false;
System.exit(0);
}
else if(menu == 2){
System.out.println(".........'Remote AC Rusak'.........");
System.out.println("----------------------------------");
RA.powerStat(pow);
RA.tempStat(temp);
RA.modeAC(mstat);
System.out.println("----------------------------------");
System.out.println("Masukan nilai temperatur");
temp = scan.nextInt();
if(temp<16){
temp = 16;
}
else if(temp>45){
temp = 45;
}
System.out.print('\u000C');//clear screen
}
else if(menu==3){
System.out.println(".........'Remote AC Rusak'.........");
System.out.println("----------------------------------");
RA.powerStat(pow);
RA.tempStat(temp);
RA.modeAC(mstat);
System.out.println("----------------------------------");
RA.modeMenu();
mstat = scan.nextInt();
System.out.print('\u000C');//clear screen
}
}
}
}
Class RemoteAC:
public class RemoteAC
{
public int Temp;
public boolean Power;
private int tempDef;
public int modeStat;
public RemoteAC(){
Temp = 25;
modeStat = 1;
Power = true;
}
public void powerStat(boolean Power){
if(Power==true){
System.out.println("Power: On");
}
else if(Power==false){
System.out.println("Power: Off");
}
}
public void tempStat(int Temp){
System.out.print("Temperature: ");
System.out.println(Temp);
}
public void modeMenu(){
System.out.println("Mode :");
System.out.println("1. AUTO");
System.out.println("2. COOL");
System.out.println("3. DRY");
System.out.println("4. FAN");
System.out.println("5. HEAT");
}
public void modeAC(int modeStat){
if(modeStat==1)
{
modeStat = 1;
System.out.println("Mode : AUTO");
}
else if(modeStat==2)
{
modeStat = 2;
System.out.println("Mode : COOL");
}
else if(modeStat==3)
{
modeStat = 3;
System.out.println("Mode : DRY");
}
else if(modeStat==4)
{
modeStat = 4;
System.out.println("Mode : FAN");
}
else if(modeStat==5)
{
modeStat = 5;
System.out.println("Mode : HEAT");
}
}
}
Komentar
Posting Komentar