Tugas Membuat Remote TV

Nama : Vinsensius Yuda Pratama
NRP   : 05111740000156



Tugas PBO B kali ini yaitu membuat remote tv sederhana menggunakan BLUE J, berikut dibawah ini adalah source code beserta screenshot hasilnya :

Fungsi main
 /**    
  * main    
  * @author Vinsensius Yuda Pratama   
  * remote tivo 1.0  
  */    
  import java.util.Scanner;    
  public class Main    
  {    
   public static void Main()    
   {    
   Scanner sc = new Scanner(System.in);    
   int menu, vol=20, ch=1,loop=1;    
   Remote_tivo key = new Remote_tivo();   
   System.out.println("#########################");   
   System.out.println("#    Blue Vision   #");  
   System.out.println("#########################");   
   while(loop==1)    
   {    
   System.out.println("  Remote Tivo  ");   
   System.out.println("1  Tivo off");   
   System.out.println("2 + Channel Up");    
   System.out.println("3 - Channel Down");    
   System.out.println("4 + Volume up");    
   System.out.println("5 - Volume down");   
   System.out.println("6  informasi");  
   menu = sc.nextInt();    
   switch(menu)    
   {   
    case 2:    
    key.upChannel();   
    ch = key.getChannel();  
    System.out.println("Channel = "+ch);    
    break;   
    case 3:    
    key.downChannel();    
    ch = key.getChannel();   
    System.out.println("Channel = "+ch);    
    break;     
    case 4:    
    key.upVolume();   
    vol = key.getVolume();   
    System.out.println("volume = "+vol);    
    break;    
    case 5:    
    key.downVolume();   
    vol = key.getVolume();  
    System.out.println("volume = "+vol);    
    break;    
    case 6:   
    ch = key.getChannel();   
    vol = key.getVolume();  
    System.out.println("Informasi Tivo");  
    System.out.println("Channel Sekarang = "+ch);   
    System.out.println("Volume Sekarang = "+vol);    
    break;   
    case 1:   
    System.out.println("Tivo dimatikan");  
    loop = 0 ;  
    break;  
   }    
   }    
   }    
  }    

Fungsi remotenya
  /**    
  * main    
  * @author Vinsensius Yuda Pratama   
  * remote tivo 1.0  
  */    
  import java.util.Scanner;   
  public class Remote_tivo    
  {    
   private int channel;    
   private int volume;    
   public Remote_tivo()    
   {    
   channel = 1;    
   volume = 20;  
   }   
   public int getChannel()    
   {    
   return channel;    
   }    
   public void upChannel()   
   {   
   if (channel==20)   
   channel=1;   
   else   
   channel = channel+1;   
   }   
   public void downChannel()   
   {   
   if(channel==1) channel=20;   
   else  
   channel=channel-1;   
   }   
   public int getVolume()    
   {    
   return volume;   
   }    
   public void downVolume()   
   {   
   if (volume>0)volume = volume-10;   
   }   
   public void upVolume()   
   {   
   if (volume<100) volume = volume+10;   
   }   
  }   

Screenshot Hasil


Komentar

Postingan populer dari blog ini

Tugas PBO B Fox n Rabbits Simulator

ETS PBO B Manless parking system

Tugas PBO Membuat Jam Digital