Tugas Membuat Software Remote Tv
1. Foto Clas-classnya
2. Kodingan Mainnya
2. Kodingan Mainnya
/**
* Membuat Software Remote Tv (Main)
*
* @author M Thalut Nadhil Q
* @version 3
*/
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
int mainmenu;
int nomor;
int channel;
int volume;
int flag = 1;
Remote remote = new Remote();
System.out.println("1. Nyalakan TV");
System.out.println("2. Ganti Channel");
System.out.println("3. Channel Sekarang");
System.out.println("4. Channel Selanjutnya");
System.out.println("5. Channel Sebelumnya");
System.out.println("6. Cek Volume");
System.out.println("7. Naikkan Volume");
System.out.println("8. Turunkan Volume");
System.out.println("9. Mute");
System.out.println("10. Matikan TV");
while(flag == 1)
{
mainmenu = scan.nextInt();
switch(mainmenu)
{
case 1:
remote.cekChannel();
break;
case 2:
System.out.println("Channel :");
System.out.println("1 - ANTV");
System.out.println("2 - RCTI");
System.out.println("3 - SCTV");
System.out.println("4 - MNC TV");
System.out.println("5 - TRANS TV");
System.out.println("6 - TRANS 7");
System.out.println("7 - TV ONE");
System.out.println("8 - NET TV");
System.out.println("9 - METRO TV");
System.out.println("10 - KOMPAS TV");
int nom = scan.nextInt();
remote.pilihanchannel(nom);
break;
case 3:
System.out.println("Channel : " +remote.cekchannel()+ "\n");
System.out.println("===================================\n");
break;
case 4:
int chan1 = remote.cekchannel();
if (chan1 < 11)
System.out.println("Channel : " +remote.majuchannel()+ "\n");
System.out.println("===================================\n");
break;
case 5:
int chan2 = remote.cekchannel();
if (chan2 > 0)
System.out.println("Channel : " +remote.mundurchannel()+ "\n");
System.out.println("===================================\n");
break;
case 6:
System.out.println("Volume : " +remote.cekvolume()+ "\n");
System.out.println("===================================\n");
break;
case 7:
int volup = remote.cekvolume();
if(volup < 50)
{
System.out.println("Volume : " +remote.volumenaik()+ "\n");
System.out.println("===================================\n");
}
else if (volup == 50)
{
System.out.println("Tolong Kecilkan Volume \n");
System.out.println("===================================\n");
}
break;
case 8:
int voldown = remote.cekvolume();
if(voldown > 0)
System.out.println("Volume : " +remote.volumeturun()+ "\n");
System.out.println("===================================\n");
break;
case 9:
System.out.println("Volume : 0 \n");
System.out.println("===================================\n");
break;
case 10:
flag = 0;
System.out.println("##########################");
System.out.println("# #");
System.out.println("# Terima Kasih #");
System.out.println("# #");
System.out.println("##########################");
break;
}
}
}
}
3. Kodingan Remot
/**
* Membuat Software Remote Tv (Remote)
*
* @author M Thalut Nadhil Q
* @version 3
*/
public class Remote
{
private int channel;
private int vol;
public Remote()
{
channel = 0;
vol = 15;
}
public void cekChannel()
{
System.out.println("##########################");
System.out.println("# Selamat Menyaksikan #");
if(channel > 0 && channel <11)
{
switch(channel)
{
case 1:
System.out.println("#\t ANTV #");
break;
case 2:
System.out.println("#\t RCTI #");
break;
case 3:
System.out.println("#\t SCTV #");
break;
case 4:
System.out.println("#\t MNC TV #");
break;
case 5:
System.out.println("#\t TRANS TV #");
break;
case 6:
System.out.println("#\t TRANS 7 #");
break;
case 7:
System.out.println("#\t TV ONE #");
break;
case 8:
System.out.println("#\t NET TV #");
break;
case 9:
System.out.println("#\t METRO TV #");
break;
case 10:
System.out.println("#\t KOMPAS TV #");
break;
}
}
else
{System.out.println("# Masukkan Nomor Channel #");}
System.out.println("# #");
System.out.println("##########################");
}
public int pilihanchannel(int nomor)
{return channel = nomor;}
public int cekchannel()
{return channel;}
public int majuchannel()
{return channel = channel + 1;}
public int mundurchannel()
{return channel = channel - 1;}
public int cekvolume()
{return vol;}
public int volumenaik()
{return vol = vol + 1;}
public int volumeturun()
{return vol = vol - 1;}
}
4. Foto Outputnya
Komentar
Posting Komentar