PBO B
Hari ini UTS pbo kelas B tentang manless ticket park system
1.Class
2.Parking
/**
* main Parking
*
* @author (Chrisnady Anggaiswara)
* @version (15/10/2018)
*/
import java.util.Scanner;
public class Parking {
public static void main(String[] args) {
Scanner scan= new Scanner(System.in);
System.out.println("Press any to continue \n");
int x,menu;
menu =0;
menu=scan.nextInt();
if(menu==1){
Ticket ticket = new Ticket("1", 2500, "RP", "2018-05-26 14:53:18", "2018-05-26 15:53:18", "KR123XC");
ticket.printTicketInfo();
}
else if(menu==2){
Ticket ticket1 = new Ticket("2", 2500, "RP", "2018-05-27 15:56:17", "2018-05-23 15:53:18", "ODIREXC");
ticket1.printTicketInfo();
} else if(menu==3){
Ticket ticket2 = new Ticket("3", 2500, "RP", "2018-05-10 10:50:10", "2018-05-20 10:50:10", "DKOEDXC");
ticket2.printTicketInfo();
} else if(menu==4){
Ticket ticket3 = new Ticket("4", 2500, "RP", "2018-05-22 15:50:10", "2018-05-25 20:50:10", "DKENFXC");
ticket3.printTicketInfo();
} else if(menu==5){
Ticket ticket4 = new Ticket("5", 2500, "RP", "2018-05-18 15:52:13", "2018-03-23 11:53:18", "SKEODXC");
ticket4.printTicketInfo();
} else {
Ticket ticket5 = new Ticket("6", 2500, "RP", "2018-05-23 13:45:18", "2018-06-22 12:50:10", "2SODEXC");
ticket5.printTicketInfo();
}
}
}
3.Ticket
/**
* main ticket
*
* @author (Chrisnady Anggaiswara)
* @version (15/10/2018)
*/
public class Ticket {
private static int count = 0;
private boolean isFilled;
private String ticketId;
private int ticketPrice;
private String currency;
private String dateOfPurchase;
private String expirationDate;
private String vehicleRegistrationNumber;
private final String emergencyPhoneNumber = "123456789";
//Constructors
public Ticket(String ticketId, int ticketPrice, String currency, String dateOfPurchase, String expirationDate, String vehicleRegistrationNumber) {
this.setTicketId(ticketId);
this.setTicketPrice(ticketPrice);
this.setCurrency(currency);
this.setDateOfPurchase(dateOfPurchase);
this.setExpirationDate(expirationDate );
this.setVehicleRegistrationNumber(vehicleRegistrationNumber);
}
//Getters and Setters
public String getTicketId() {
return ticketId;
}
public void setTicketId(String ticketId) {
this.ticketId = ticketId;
}
public int getTicketPrice() {
return ticketPrice;
}
public void setTicketPrice(int ticketPrice) {
this.ticketPrice = ticketPrice;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getDateOfPurchase() {
return dateOfPurchase;
}
public void setDateOfPurchase(String dateOfPurchase) {
this.dateOfPurchase = dateOfPurchase;
}
public String getExpirationDate() {
return expirationDate;
}
public void setExpirationDate(String expirationDate) {
int a = 0;
a = a+1;
this.expirationDate = expirationDate+a;
}
private String getVehicleRegistrationNumber() {
return vehicleRegistrationNumber;
}
private void setVehicleRegistrationNumber(String vehicleRegistrationNumber) {
this.vehicleRegistrationNumber = vehicleRegistrationNumber;
}
private String getEmergencyPhoneNumber() {
return emergencyPhoneNumber;
}
//Method to print information about ticket
public void printTicketInfo() {
System.out.println("########################################");
System.out.println("########################################");
System.out.println("########################################");
String ticketInformation = " Ticket ID: " + getTicketId() + "\n" +
" Ticket price: " + getTicketPrice() + getCurrency() + "\n" +
" Purchase date: " + getDateOfPurchase() + "\n" +
" Expiration date: " + getExpirationDate() + "\n" +
" Vehicle registration number: " + getVehicleRegistrationNumber() + "\n" +
" Emergency phone number: " + getEmergencyPhoneNumber();
System.out.println(ticketInformation);
System.out.println("########################################");
System.out.println("########################################");
System.out.println("########################################");
}
}