Tugas Membuat Remote TV
Hari ini membuat post tentang tugas remote TV,remote TV yang saya buat hanya sederhana seperti tugas sebelumnya,semoga dapat dipahami.
Chrisnady Anggaiswara
5111640000153
PBO-B
1.Screenshot Hasil dan Class
2.Main
import java.util.Scanner;
/**
* Menjalankan Remot TV
*
* @author (Chrisnady Anggaiswara)
* @version (8.2/23092018)
*/
public class Main
{
public static void main(String args[]){
Scanner scan= new Scanner(System.in);
int jumlahvolume,jumlahchannel, menu;
boolean entry;
System.out.println("|=============================|");
System.out.println("| Welcome To |");
System.out.println("| Chris Angga TV |");
System.out.println("|=============================|");
System.out.println("Masukkan Volume Saat Ini : ");
jumlahvolume = scan.nextInt();
System.out.println("|=============================|");
System.out.println("Masukkan Channel Saat Ini : ");
jumlahchannel = scan.nextInt();
System.out.println("|=============================|");
Remote KS = new Remote(jumlahvolume,jumlahchannel);
entry = true;
while(entry) {
System.out.println("Daftar Menu :");
System.out.println("1. Volume Saat Ini");
System.out.println("2. Channel Saat Ini");
System.out.println("3. Naikkan Volume");
System.out.println("4. Turunkan Volume");
System.out.println("5. Naikkan Channel");
System.out.println("6. Turunkan Channel");
System.out.println("7. Exit");
System.out.println("Menu Yang Dipilih : ");
menu=scan.nextInt();
System.out.println("|=============================|");
switch(menu){
case 1:
jumlahvolume=KS.GetVolume();
System.out.println("Volume Saat Ini : "+jumlahvolume);
System.out.println("|=============================|");
break;
case 2:
jumlahchannel = KS.GetChannel();
if(jumlahchannel == 1){
System.out.println("|=============================|");
System.out.println("| FFFTV |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
}
else if(jumlahchannel == 2){
System.out.println("|=============================|");
System.out.println("| RRTI |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
System.out.println("");
}
else if(jumlahchannel == 3){
System.out.println("|=============================|");
System.out.println("| SOMY TV |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
} else{
System.out.println("|=============================|");
System.out.println("| NotFound |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
}
System.out.println("|=============================|");
break;
case 3:
KS.TambahVolume();
System.out.println("|=============================|");
break;
case 4:
KS.KurangVolume();
System.out.println("|=============================|");
break;
case 5:
jumlahchannel = KS.TambahChannel();
if(jumlahchannel == 1){
System.out.println("|=============================|");
System.out.println("| FFFTV |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
}
else if(jumlahchannel == 2){
System.out.println("|=============================|");
System.out.println("| RRTI |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
System.out.println("");
}
else if(jumlahchannel == 3){
System.out.println("|=============================|");
System.out.println("| SOMY TV |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
} else{
System.out.println("|=============================|");
System.out.println("| NotFound |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
}
System.out.println("|=============================|");
break;
case 6:
jumlahchannel = KS.KurangChannel();
if(jumlahchannel == 1){
System.out.println("|=============================|");
System.out.println("| FFFTV |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
}
else if(jumlahchannel == 2){
System.out.println("|=============================|");
System.out.println("| RRTI |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
System.out.println("");
}
else if(jumlahchannel == 3){
System.out.println("|=============================|");
System.out.println("| SOMY TV |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
} else{
System.out.println("|=============================|");
System.out.println("| NotFound |");
System.out.println("| Channel Saat ini : "+jumlahchannel+" |");
System.out.println("|=============================|");
}
System.out.println("|=============================|");
break;
case 7:
System.out.println("| TV Telah Dimatikan |");
System.out.println("|=============================|");
entry = false;
break;
}
}
}
}
3.Remote
import java.util.Scanner;
/**
* Remot TV
*
* @author (Chrisnady Anggaiswara)
* @version (8.1/20092018)
*/
public class Remote
{
private int volume;
private int channel;
public Remote(int jumlahvolume,int jumlahchannel){
volume = jumlahvolume;
channel = jumlahchannel;
}
public int GetVolume(){
return volume;
}
public int GetChannel(){
return channel;
}
public void TambahVolume()
{
if(volume == 15){
System.out.println("Volumenya Sudah Full Kak :(");
}
else{
volume= volume+1;
System.out.println("Volumenya Saat ini : "+volume);
}
}
public void KurangVolume()
{
if(volume == 0){
System.out.println("Volumenya Sudah 0 Kak :(");
}
else{
volume= volume-1;
System.out.println("Volumenya Saat ini : "+volume);
}
}
public int TambahChannel()
{
channel = channel+1;
return channel;
}
public int KurangChannel()
{
channel = channel-1;
return channel;
}
}
Thank You
Tidak ada komentar:
Posting Komentar