Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Servermaster Servermaster is offline
Member Aktif
 
Join Date: Nov 2011
Posts: 257
Rep Power: 14
Servermaster mempunyai hidup yang Normal
Default [ask] about exception handling java

Tanya gan, berkaitan dengan exception handling...

Jadi codenya begini di kelas main :


Code:

public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Mobil mob = new Mobil();
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
int x=0,panjang = 0,lebar = 0;
String merek = "", platNo = "", bahanBakar = "", warna = "";
LinkedList listKomponen = new LinkedList();
do{
try{
System.out.println("=====MENU=====\n"+
"1. Masukkan Mobil Baru\n"+
"2. Tampil Semua Data Mobil\n"+
"3. Keluar \n Pilihan anda : ");
x = input.nextInt();

switch(x){
case 1 :
try{
System.out.println("merk : ");
merek = b.readLine();
System.out.println("Plat No ; ");
platNo = b.readLine();
System.out.println("Warna : ");
warna = b.readLine();
System.out.println("Bahan bakar : ");
bahanBakar = b.readLine();
System.out.println("Panjang : ");
panjang = input.nextInt();
System.out.println("Lebar : ");
lebar = input.nextInt();
checkMerk(merek, listKomponen);
checkBB(bahanBakar, listKomponen);
checkLebar(lebar);
checkPanjang(panjang);
checkPlat(platNo, listKomponen);


}
catch(merkException me){
System.out.println(me.getMessage());
}
catch(bbException bbe){
System.out.println(bbe.getMessage());
}
catch(rangeException re){
System.out.println(re.getMessage());
}
catch(platNoException pne){
System.out.println(pne.getMessage());
}
catch(Exception E){}
mob = new Mobil(merek, warna, platNo, bahanBakar, panjang, lebar);
listKomponen.add(mob);
break;
case 2 :
printListKomponen(listKomponen);

break;

}
}
catch(Exception E){}

}
while(x!=3);

}

public static void printListKomponen(LinkedList

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 08:18 PM.


no new posts