import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class tipi extends tp{
superclass*/
String kecerahan;
int pilihan;
public tipi(){
super(); //keyword turunan
kecerahan="";
}
public tipi (String newChannel, String newVolume,
String newModern, String newHidup, String newMati, String newKecerahan ){
super (newChannel, newVolume, newModern, newHidup, newMati);
kecerahan=newKecerahan;
}
public void setKecerahan(String newKecerahan){
kecerahan=newKecerahan;
}
public void getKecerahan(){
// return kecerahan;
}
public String tuString(){
String str=
"CHANNEL :"+channel+"\n"+
"VOLUME :"+volume+"\n"+
"MODERN :"+modern+"\n"+
"HIDUP :"+hidup+"\n"+
"MATI :"+mati+"\n"+
"KECERAHAN:"+kecerahan+"\n";
return str;
}
public static void main(String[] args)throws IOException {
BufferedReader br= new BufferedReader (new InputStreamReader (System.in));
int a=1; //inisialisasi variabel
do{ //proses perulangan
System.out.println("\n\n== Pilihan : ==");
System.out.println("1 : Channel");
System.out.println("2 : Volume");
System.out.println("3 : Modern");
System.out.println("4 : Hidup");
System.out.println("5 : mati");
System.out.println("6 : Keluar");
System.out.print("\nPilihan Anda : ");
System.out.println("masukkan pilihan anda??");
int pilihan=Integer.parseInt(br.readLine());
switch(pilihan) {
case 1: //pilihan jika dimasukkan angka 1
System.out.println("masukkan channel yang anda inginkan???");
String channel=br.readLine(); //proses baca data yang diinputkan dalam keyboard
System.out.println("anda memilih channel:"+channel);
break;
case 2:
System.out.println("masukkan volume yang anda inginkan????");
String volume=br.readLine();
System.out.println("volume channel sekarang:"+volume);
break;
case 3:
System.out.println("masukkan modern yang anda inginkan???");
String modern=br.readLine();
System.out.println("anda sedang memilih:"+modern);
break;
case 4:
System.out.println("apakah tv hidup???");
String hidup=br.readLine();
System.out.println("sekarang keadaan tv:"+hidup);
break;
case 5:
System.out.println("apakah kondisi tv mati???");
String mati=br.readLine();
System.out.println("sekarang kondisi tv:"+mati);
break;
case 6 :
System.exit(0); //menandakan program selesai jika pilihan angka 6
break;
default:System.out.print("Pilihan Salah!");
}
}
while(a==1);
test();
}
}
Minggu, 14 Oktober 2012
CLASS UTAMA PROGRAM TV
package tv;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class TV {
public String channel;
public String volume;
public String modern;
public String hidup;
public String mati;
public TV(){//membuat intance baru
channel="";
volume="";
modern="";
hidup="";
mati="";
}
public TV (String newChannel, String newVolume, String newModern,
String newHidup, String newMati){
channel=newChannel;
volume=newVolume;
modern=newModern;
hidup=newHidup;
mati=newMati;
}
public void setChannel (String newChannel){
channel=newChannel;
}
public void setVolume (String newVolume){
volume=newVolume;
}
public void setModern (String newModern){
modern=newModern;
}
public void setHidup (String newHidup){
hidup=newHidup;
}
public void setMati (String newMati){
mati=newMati;
}
public String getChannel(){
return channel;
}
public String getVolume(){
return volume;
}
public String getModern(){
return modern;
}
public String getHidup(){
return hidup;
}
public String getMati(){
return mati;
}
public String tuString(){
String str=
"CHANNEL :"+channel+"\n"+
"VOLUME :"+volume+"\n"+
"MODERN :"+modern+"\n"+
"HIDUP :"+hidup+"\n"+
"MATI :"+mati+"\n";
return str;
}
static void test(){
//TURUNAN t=new TURUNAN (/*"SCTV","25","internet","hidup","mati"*/);
/*Scanner c=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getChannel());
channel=c.nextLine();
Scanner d=new Scanner(System.in);
System.out.println("masukkan volume yang anda inginkan"+t.getVolume());
volume=d.nextLine();
Scanner e=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getModern());
modern=e.nextLine();
Scanner f=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getHidup());
hidup=f.nextLine();
Scanner g=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getMati());
mati=g.nextLine();*/
/*System.out.println(t.getChannel());
System.out.println(t.getVolume());
System.out.println(t.getModern());
System.out.println(t.getHidup());
System.out.println(t.getMati());*/
}
public static void main(String[] args)throws IOException {
BufferedReader br= new BufferedReader (new InputStreamReader (System.in));
test();
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class TV {
public String channel;
public String volume;
public String modern;
public String hidup;
public String mati;
public TV(){//membuat intance baru
channel="";
volume="";
modern="";
hidup="";
mati="";
}
public TV (String newChannel, String newVolume, String newModern,
String newHidup, String newMati){
channel=newChannel;
volume=newVolume;
modern=newModern;
hidup=newHidup;
mati=newMati;
}
public void setChannel (String newChannel){
channel=newChannel;
}
public void setVolume (String newVolume){
volume=newVolume;
}
public void setModern (String newModern){
modern=newModern;
}
public void setHidup (String newHidup){
hidup=newHidup;
}
public void setMati (String newMati){
mati=newMati;
}
public String getChannel(){
return channel;
}
public String getVolume(){
return volume;
}
public String getModern(){
return modern;
}
public String getHidup(){
return hidup;
}
public String getMati(){
return mati;
}
public String tuString(){
String str=
"CHANNEL :"+channel+"\n"+
"VOLUME :"+volume+"\n"+
"MODERN :"+modern+"\n"+
"HIDUP :"+hidup+"\n"+
"MATI :"+mati+"\n";
return str;
}
static void test(){
//TURUNAN t=new TURUNAN (/*"SCTV","25","internet","hidup","mati"*/);
/*Scanner c=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getChannel());
channel=c.nextLine();
Scanner d=new Scanner(System.in);
System.out.println("masukkan volume yang anda inginkan"+t.getVolume());
volume=d.nextLine();
Scanner e=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getModern());
modern=e.nextLine();
Scanner f=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getHidup());
hidup=f.nextLine();
Scanner g=new Scanner(System.in);
System.out.println("masukkan channel yang anda inginkan"+t.getMati());
mati=g.nextLine();*/
/*System.out.println(t.getChannel());
System.out.println(t.getVolume());
System.out.println(t.getModern());
System.out.println(t.getHidup());
System.out.println(t.getMati());*/
}
public static void main(String[] args)throws IOException {
BufferedReader br= new BufferedReader (new InputStreamReader (System.in));
test();
}
}
Langganan:
Postingan (Atom)