Tugas Remot AC
Main Class
import java.util.Scanner;
public class IntMain
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
System.out.println("====================");
System.out.println("=== ===");
System.out.println("=____ Remot AC ____=");
System.out.println("=== ===");
System.out.println("====================");
int mode;
int input;
System.out.println("Apakah anda ingin menyalakan AC? (1)");
Remote remote = new Remote();
input = scan.nextInt();
while (input != 1 )
{
System.out.println("Ketik 1 untuk menyalakan AC");
input = scan.nextInt();
}
remote.menu();
input = 0;
while(input !=1)
{
input = scan.nextInt();
switch(input){
case 2:
remote.suhunaik();
break;
case 3:
remote.suhuturun();
break;
case 4:
remote.fanUp();
break;
case 5:
remote.fanDown();
break;
}
}
System.exit(0);
}
}
Remote Class
import java.util.Scanner;
public class Remote
{
private int suhu, kipas;
public Remote()
{
kipas = 1;
suhu = 24;
}
public void suhunaik()
{
if (suhu == 32 )
{
System.out.println("Suhu Sudah paling Tinggi");
return;
}
suhu++;
menu();
}
public void suhuturun()
{
if (suhu == 16 )
{
System.out.println("Suhu Sudah Paling Rendah");
return;
}
suhu--;
menu();
}
public void fanUp()
{
if (kipas == 1 )
{
System.out.println("Kipas Sudah Paling Tinggi");
return;
}
kipas++;
menu();
}
public void fanDown()
{
if (kipas == 5 )
{
System.out.println("Kipas Sudah Paling Rendah");
return;
}
kipas--;
menu();
}
public void menu()
{
System.out.println("|======================|");
System.out.println("|---- INI REMOT AC ----|");
System.out.println("| " + suhu + " °C |");
System.out.println("| SPEED " + kipas + " |");
System.out.println("|-------- MENU --------|");
System.out.println("| 2.Temperature ↑ |");
System.out.println("| 3.Temperature ↓ |");
System.out.println("| 4.Fan Speed ↑ |");
System.out.println("| 5.Fan Speed ↓ |");
System.out.println("|======================|");
System.out.println("|======================|");
System.out.println();
}
}
Komentar
Posting Komentar