UTS PBO

Nama: Donny Fitrado
NRP: 05111740000171
Kelas: PBO A

Class Detector:
 import java.lang.String;  
 import java.util.Scanner;  
 /**  
  * Sebagai penerima input  
  *  
  * @author Donny Fitrado  
  * 05111740000171  
  * PBO A  
  */  
 public class Detector  
 {  
   private int jenis_kendaraan;  
   private String nopol;  
   private int durasi;  
   private String rekening;  
   private Scanner input;  
   public Detector()  
   {  
     input = new Scanner(System.in);  
   }  
   public void MenuInput()  
   {  
     System.out.println("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");  
     System.out.println("Selamat Datang di E-Parking");  
     System.out.println("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");  
     jenis_kendaraan = 0;  
     while(jenis_kendaraan != 1 && jenis_kendaraan != 2)  
     {  
       System.out.println("");  
       System.out.println("Silahkan pilih jenis kendaraan");  
       System.out.println("1. Motor");  
       System.out.println("2. Mobil");  
       System.out.print("Pilihan : ");  
       jenis_kendaraan = input.nextInt();  
     }  
     System.out.println("");  
     System.out.print("Silahkan masukkan nomor polisi: ");  
     nopol = input.next();  
     durasi = 0;  
     while(durasi != 1 && durasi != 2 && durasi != 3)  
     {  
       System.out.println("");  
       System.out.println("Silahkan pilih durasi parkir");  
       System.out.println("1. 12 jam");  
       System.out.println("2. 1 hari (inap)");  
       System.out.println("3. 3 hari (inap)");  
       System.out.print("Pilihan : ");  
       durasi = input.nextInt();  
     }  
     System.out.println("");  
     System.out.print("Silahkan tempelkan kartu pembayaran (Masukkan rekening): ");  
     rekening = input.next();  
     System.out.println("");  
     System.out.println("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");  
     System.out.println("Silahkan mengambil kedua karcis");  
     System.out.println("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒");  
     System.out.println("");  
   }  
   public int getJenis()  
   {  
     return jenis_kendaraan;  
   }  
   public String getNopol()  
   {  
     return nopol;  
   }  
   public int getDurasi()  
   {  
     return durasi;  
   }  
   public String getRekening()  
   {  
     return rekening;  
   }  
 }  


Class Mechanism:
 /**  
  * Penghubung Detector dan Printing  
  *  
  * @author Donny Fitrado  
  * @version 0.1  
  */  
 public class Mechanism  
 {  
   public Detector detectobj;  
   public Printing printobj;  
   public Mechanism()  
   {  
     detectobj = new Detector();  
     printobj = new Printing();  
     detectobj.MenuInput();  
     for(int a = 0; a < 2; a++)  
     {  
       printobj.PrintKarcis(detectobj.getJenis(), detectobj.getNopol(), detectobj.getDurasi(), detectobj.getRekening());  
       System.out.println("");  
     }  
     System.out.println("Terima kasih telah menggunakan E-Parking");  
   }  
 }  


Class Printing:
 /**  
  * Output(print)  
  *  
  * @author Donny Fitrado  
  * @version 05111740000171  
  */  
 public class Printing  
 {  
   public void PrintKarcis(int jenis, String nopol, int durasi, String rekening)  
   {  
     System.out.println("####################");  
     System.out.println("-DINAS PERHUBUNGAN");  
     System.out.println("  KOTA SURABAYA-");  
     System.out.println("Surabaya / 00000018 / 10");  
     System.out.println("Mulai : 15/10/2018");  
     switch(durasi)  
     {  
       case 1:  
       System.out.println("Selesai : 15/10/2018");  
       break;  
       case 2:  
       System.out.println("Selesai : 16/10/2018");  
       break;  
       case 3:  
       System.out.println("Selesai : 18/10/2018");  
       break;  
     }  
     switch(jenis)  
     {  
       case 1:  
       System.out.print("Motor / ");  
       break;  
       case 2:  
       System.out.print("Mobil / ");  
       break;  
     }  
     System.out.println(nopol);  
     switch(durasi)  
     {  
       case 1:  
       System.out.println("Tarif Parkir : Rp4000");  
       break;  
       case 2:  
       System.out.println("Tarif Parkir : Rp50000");  
       break;  
       case 3:  
       System.out.println("Tarif Parkir : Rp100000");  
       break;  
     }  
     switch(durasi)  
     {  
       case 1:  
       System.out.println("Saldo Akhir : Rp996000");  
       break;  
       case 2:  
       System.out.println("Saldo Akhir : Rp950000");  
       break;  
       case 3:  
       System.out.println("Saldo Akhir : Rp900000");  
       break;  
     }  
     System.out.println(rekening);  
     System.out.println("####################");  
   }  
 }  

Tampilan Workspace:


Ketika dijalankan:

Terima kasih dan mohon maaf apabila ada kesalaham.

Comments

Popular posts from this blog

EAS PBKK A

Tugas 2 - Pemrograman Web

Tugas PBO - Tech Support