1. Reader
public class Reader
{
private InputReader reader;
public int kendaraan = 0;
public int durasi = 0;
public String nopol;
public void createReader(){
reader = new InputReader();
kendaraan = getKendaraan();
nopol = getNopol();
durasi = getDurasi();
}
public int getKendaraan(){
System.out.println ("===========================================");
System.out.println ("===========================================");
System.out.println (" Selamat Datang di Taman Bungkul ");
System.out.println (" Silahkan Masukkan Jenis Kendaraan Anda ");
System.out.println (" 1. Mobil ");
System.out.println (" 2. Motor ");
System.out.println ("===========================================");
System.out.println ("===========================================");
int kendaraan = reader.getInt();
return kendaraan;
}
public String getNopol(){
System.out.println ("===========================================");
System.out.println ("===========================================");
System.out.println (" Silahkan Masukkan Nopol Kendaraan Anda ");
System.out.println ("===========================================");
System.out.println ("===========================================");
String nopol = reader.getInput();
return nopol;
}
public int getDurasi(){
System.out.println ("===========================================");
System.out.println ("===========================================");
System.out.println (" Silahkan Masukkan Durasi Parkir Anda ");
System.out.println ("===========================================");
System.out.println ("===========================================");
int durasi = reader.getInt();
return durasi;
}
}
2.Input Reader
import java.util.Scanner;
public class InputReader
{
public String getInput()
{
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
return input;
}
public int getInt(){
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
return input;
}
}
3. Tiket
/**
* Jenis Kendaraan
*
* Sherly Rosa Anggraeni
* 05111740000018
*/
import java.util.Scanner;
public class Ticketing
{
private InputReader input;
private Reader reader;
private int biaya = 0;
public Ticketing()
{
input = new InputReader();
reader = new Reader();
}
public void printTicket(){
System.out.println("####################Tiket1#####################");
System.out.println("Jenis kendaraan : " + reader.kendaraan);
System.out.println("Nomor polisi : " + reader.nopol);
System.out.println("Durasi : " + reader.durasi + "jam");
System.out.println("Biaya Parkir : Rp 3000" );
System.out.println("##############################################");
System.out.println();
System.out.println("####################Tiket2#####################");
System.out.println("Jenis kendaraan : " + reader.kendaraan);
System.out.println("Nomor polisi : " + reader.nopol);
System.out.println("Durasi : " + reader.durasi + "jam");
System.out.println("Biaya Parkir : Rp 3000" );
System.out.println("##############################################");
System.out.println();
} }
Output
Tidak ada komentar:
Posting Komentar