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: 15
Servermaster mempunyai hidup yang Normal
Default [ask] about exception handling java

Tanya gan, berkaitan dengan exception handling...

Jadi codenya begini di kelas main :

<div style="margin:20px; margin-top:5px">
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


Terkait
Thread Thread Starter Forum Replies Last Post
JUAL Reptile Handling Gloves untuk handling varanus, iguana,dan reptil yang berkuku tajam TokoPetShop Fauna (Hewan) 0 19th October 2012 09:02 PM
JUAL Reptile Handling Gloves untuk handling varanus iguana dan reptil yang berkuku tajam TokoPetShop Fauna (Hewan) 0 19th October 2012 12:16 PM
Reptile Handling Gloves untuk handling varanus, iguana,dan reptil yang berkuku tajam PetOPedia Fauna (Hewan) 0 19th October 2012 10:12 AM
JUAL Reptile Handling Gloves untuk handling varanus, iguana,dan reptil yang berkuku tajam AnjingRas Fauna (Hewan) 0 19th October 2012 09:11 AM
tanya masalah j2me..eror nullpointer java/lang/nullpointer exception Permenkaret Programming 0 20th November 2011 12:18 PM

 


All times are GMT +7. The time now is 01:56 AM.