Skip to main content

E-Parking Ticket Machine

Pembuatan E-Parking Ticket Machine dengan 3 class

  • Detector : Sebagai penerima input
  • Mechanism : Sebagai penghubung
  • Printing : Sebagai output
masing - masing memiliki source code sebagai berikut :

Detector Source Code
import java.lang.String;
import java.util.Scanner;
/**
 * Sebagai penerima input
 *
 * @author Satria Ade Veda Karuniawan
 * @version 0.1
 */
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;
    }
}

Mechanism Source Code

/**
 * Sebagai penghubung Detector dan Printing
 *
 * @author Satria Ade Veda Karuniawan
 * @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");
    }
}

Printing Source Code
/**
 * Sebagai output
 *
 * @author Satria Ade Veda Karuniawan
 * @version 0.1
 */
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("▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓");

    }
}

Screenshot Workspace

Simulasi

Comments

Popular posts from this blog

Technical Support AI

Technical Support - Artificial Intelligence (*From now on, I'll try my best to explain about all of my Project using English) For this project, I made 3 classes to control the Bot Mechanism (Referencing to Objects-First-with-Java-A-Practical-Introduction-Using-BlueJ-David-J-Barnes pages 155) : InputReader Class (Used for detect or to take any user input) SupportSystem Class (As a main function connecting the user input and database) Responder Class (Handling AI-Output and Its role as 'mini' database) Current Version : 1.2 In the future, I'm expecting to have a bigger Responder's Database and would be separated from the Class itself, so it will be easier to make some modification inside the AI's Database and easier to manage. And then i'll try to improve the UX Design inside, so that the user can have a feeling about how 'Human' this AI. InputReader Class In this class, pretty much the same as how the name of the class is writt...

Fox And Rabbit

Implementasi Fox and Rabbit berupa simulasi hubungan antara predator (dalam hal ini Fox) dan prey (dalam hal ini Rabbit), digunakan 9 class : Simulator (sebagai class utama yang digunakan untuk melakukan simulasi) SimulatorView (sebagai pengatur tampilan yang diimplementasikan pada class Simulator) Field (sebagai class yang mengatur dan memanipulasi bidang simulasi yang telah ditentukan) FieldStats (sebagai class berupa value holder yang menyimpan kondisi dari Field) Counter (sebagai class penghitung seperti increment dan reset value) Location (sebagai class yang memiliki informasi posisi pada Field) Randomizer (sebagai class yang mengatur nilai random) Fox (sebagai class simulator yang bertindak sebagai predator) Rabbit (sebagai class simulator yang bertindak sebagai prey) Source Code Simulator import java.util.Random; import java.util.List; import java.util.ArrayList; import java.util.Iterator; import java.awt.Color; import java.util.concurrent.TimeUnit; impo...

Ticketing Machine

Pembuatan simulasi Ticketing Machine menggunakan OOP Class yang digunakan di dalam Project terdiri atas : Main class TicketMachine class Destination class Library yang digunakan di dalam Project adalah java.util.Scanner Source code Destination class /**  * A class which describes Destination  *  * @author Satria Ade Veda Karuniawan  * @version version 1.0  */ public class Destination {     private String Station;     private int PriceAdult;     private int PriceChild;     //Struct destination       public Destination(String name)     {         Station = name;         PriceAdult = 0;         PriceChild = 0;     }       public void SetInfo(int pa, int pc)     {         PriceAdult = pa;         PriceChild = pc;   ...