Nama : Edgar Andrew Hutauruk
NRP : 05111740000166
Kelas : PBO-B
CLASS REMOT TV
CLASS MAIN
NRP : 05111740000166
Kelas : PBO-B
CLASS REMOT TV
/**
* Write a description of class Remote here.
*
* @author (Edgar Andrew Hutauruk)
* @version (24/09/2018)
*/
public class remot
{
public int volume;
public int channel;
public remot(int vol,int ch)
{
volume = vol;
channel = ch;
}
public int channelsekarang()
{
System.out.println("Channel :"+channel);
return channel;
}
public int volumesekarang()
{
System.out.println("Volume :"+volume);
return volume;
}
public void volumetambah()
{
if(volume==50){
System.out.println("+++++++++++++++");
System.out.println("Max Volume");
System.out.println("+++++++++++++++");
}
else
{
volume = volume+1;
System.out.println("+++++++++++++++");
System.out.println("Volume :"+volume);
System.out.println("+++++++++++++++");
}
}
public void volumekurang()
{
if(volume==0){
System.out.println("---------------");
System.out.println("Mute");
System.out.println("---------------");
}
else
{
volume = volume-1;
System.out.println("---------------");
System.out.println("Volume :"+volume);
System.out.println("---------------");
}
}
public void channelkurang()
{
if(channel==0){
System.out.println("===============");
System.out.println("Channel : 0");
System.out.println("===============");
}
else
{
channel = channel-1;
System.out.println("===============");
System.out.println("Channel :"+channel);
System.out.println("===============");
}
}
public void channeltambah()
{
if(channel==100){
System.out.println("===============");
System.out.println("Channel : 100");
System.out.println("===============");
}
else
{
channel = channel+1;
System.out.println("===============");
System.out.println("Channel :"+channel);
System.out.println("===============");
}
}
}
CLASS MAIN
/**
* Write a description of class main here.
*
* @author (Edgar Andrew Hutauruk)
* @version (24/09/2018)
*/
import java.util.Scanner;
public class main
{
public static void main()
{
Scanner scan = new Scanner(System.in);
int vol,menu,chn;
System.out.println("+_+_+_+_+_+_+_+_+_+_+_+_+");
System.out.println("+_+_+_+_Remot Tv_+_+_+_+");
System.out.println("+_+_+_+_+_+_+_+_+_+_+_+_+");
System.out.println("Masukkan Besar Volume Saat ini : ");
System.out.println("+_+_+_+_+_+(1-30)+_+_+_+_+");
vol = scan.nextInt();
while(vol>30){
System.out.println("Volume terlalu besar bisa merusak pendengaran anda");
vol = scan.nextInt();
}
System.out.println("Masukkan Nomor Channel Saat ini :");
chn = scan.nextInt();
remot remotTV =new remot(vol,chn);
System.out.println("======================");
System.out.println("=========MENU=========");
System.out.println("======================");
System.out.println("1. Volume Saat ini");
System.out.println("2. Channel Saat ini");
System.out.println("3. Tambah Volume");
System.out.println("4. Kurang Volume");
System.out.println("5. Tambah Channel");
System.out.println("6. Kurang Channel");
System.out.println("7. Exit");
while(true)
{
menu=scan.nextInt();
if(menu==1)
{
remotTV.volumesekarang();
}
else if(menu==2)
{
remotTV.channelsekarang();
}
else if(menu==3)
{
if(vol>50){
System.out.println("MAX. VOLUME");
System.out.println("======================");
}
else{
remotTV.volumetambah();
}
}
else if(menu==4)
{
remotTV.volumekurang();
}
else if(menu==5)
{
remotTV.channeltambah();
}
else if(menu==6)
{
remotTV.channelkurang();
}
else if(menu==7)
{
break;
}
}
}
}
Komentar
Posting Komentar