Skip to content

Commit

Permalink
update UserController
Browse files Browse the repository at this point in the history
  • Loading branch information
fakhriaunur committed Nov 28, 2019
1 parent 47fbbf0 commit 1dbea00
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 22 deletions.
32 changes: 32 additions & 0 deletions src/main/java/org/kelompok4/app/Controller/ReportController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.kelompok4.app.Controller;

import org.kelompok4.app.Interface.ICanRead;
import org.kelompok4.app.Model.BookingModel;
import org.kelompok4.app.View.ReportView;

public class ReportController implements ICanRead {
private BookingModel bookingModel;
//private TrainScheduleModel trainScheduleModel;
private ReportView reportView;


@Override
public void read() {

}



//unsolid
public void showDailyReport() {

}

public void showMonthlyReport() {

}

public void showAnnualReport() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.kelompok4.app.Interface;

public interface ICanManageReport {

void generate();
}
26 changes: 16 additions & 10 deletions src/main/java/org/kelompok4/app/Model/BookingModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@

import java.util.ArrayList;

enum Status {
UNPAID,
PAID,
EXPIRED
}

public class BookingModel {
private String bookingCode;
private String codeSchedule;
private String scheduleCode;
private String trainCode;
private String virtualAccount;
private ArrayList<String> passenger;
private ArrayList<String> seatCode;
private boolean paid; // jadi private enum UNPAID, PAID, EXPIRED, CANCELLED
private Status paid; // jadi private enum UNPAID, PAID, EXPIRED, CANCELLED
private PriceModel totalPayment;

public BookingModel() {
}

public BookingModel(String codeSchedule, String trainCode, String bookingCode, String virtualAccount, ArrayList<String> passenger, ArrayList<String> seatCode, boolean paid, PriceModel totalPayment) {
this.codeSchedule = codeSchedule;
public BookingModel(String scheduleCode, String trainCode, String bookingCode, String virtualAccount, ArrayList<String> passenger, ArrayList<String> seatCode, Status paid, PriceModel totalPayment) {
this.scheduleCode = scheduleCode;
this.trainCode = trainCode;
this.bookingCode = bookingCode;
this.virtualAccount = virtualAccount;
Expand All @@ -26,12 +32,12 @@ public BookingModel(String codeSchedule, String trainCode, String bookingCode, S
this.totalPayment = totalPayment;
}

public String getCodeSchedule() {
return codeSchedule;
public String getScheduleCode() {
return scheduleCode;
}

public void setCodeSchedule(String codeSchedule) {
this.codeSchedule = codeSchedule;
public void setScheduleCode(String code) {
this.scheduleCode = code;
}

public String getTrainCode() {
Expand Down Expand Up @@ -74,11 +80,11 @@ public void setSeatCode(ArrayList<String> seatCode) {
this.seatCode = seatCode;
}

public boolean isPaid() {
public Status getPaid() {
return paid;
}

public void setPaid(boolean paid) {
public void setPaid(Status paid) {
this.paid = paid;
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/kelompok4/app/Model/CoachModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import java.util.ArrayList;

public class CoachModel {
private int maxSeat; // replace with seatQty
private int seatQty; // replace with seatQty
private ArrayList<SeatModel> seat = new ArrayList<SeatModel>();

public CoachModel(int maxSeat, ArrayList<SeatModel> seat) {
this.maxSeat = maxSeat;
public CoachModel(int seatQty, ArrayList<SeatModel> seat) {
this.seatQty = seatQty;
this.seat = seat;
}

public CoachModel() {
}

public int getMaxSeat() {
return maxSeat;
public int getSeatQty() {
return seatQty;
}

public void setMaxSeat(int maxSeat) {
this.maxSeat = maxSeat;
public void setSeatQty(int seatQty) {
this.seatQty = seatQty;
}

public ArrayList<SeatModel> getSeat() {
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/kelompok4/app/Model/SeatModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,22 @@ public SeatModel(int status, int number) {
this.status = status;
this.number = number;
}

public SeatModel() {}

public int getStatus() {
return status;
}

public void setStatus(int status) {
this.status = status;
}

public int getNumber() {
return number;
}

public void setNumber(int number) {
this.number = number;
}
}
87 changes: 82 additions & 5 deletions src/main/java/org/kelompok4/app/Model/TrainScheduleModel.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package org.kelompok4.app.Model;

import java.util.Date;
import java.time.LocalDate;

public class TrainScheduleModel {
private String scheduleCode;
private TimeModel timeModel;
private Date date;
private LocalDate date;
private RwRouteModel rwRouteModel;
private TrainModel trainModel;

public TrainScheduleModel() {
}

public TrainScheduleModel(String scheduleCode, TimeModel timeModel, Date date, RwRouteModel rwRouteModel, TrainModel trainModel) {
public TrainScheduleModel(String scheduleCode, TimeModel timeModel, LocalDate date, RwRouteModel rwRouteModel, TrainModel trainModel) {
this.scheduleCode = scheduleCode;
this.timeModel = timeModel;
this.date = date;
Expand All @@ -35,11 +36,11 @@ public void setTimeModel(TimeModel timeModel) {
this.timeModel = timeModel;
}

public Date getDate() {
public LocalDate getDate() {
return date;
}

public void setDate(Date date) {
public void setDate(LocalDate date) {
this.date = date;
}

Expand All @@ -58,4 +59,80 @@ public TrainModel getTrainModel() {
public void setTrainModel(TrainModel trainModel) {
this.trainModel = trainModel;
}

public String getDateString(){
String output = "";
output += date.toString().split(" ")[0];
output += " ";
output += date.toString().split(" ")[1];
output += " ";
output += date.toString().split(" ")[2];
output += " ";
output += date.toString().split(" ")[5];
return output;
}

public String getDepartureTimeString(){
String output = "";
output += timeModel.getJam().getHH();
output += ":";
output += timeModel.getJam().getMM();
return output;
}

public String getArrivalTimeString(){
String output = "";
int totalDuration = 0;
for (RwTrackModel r : rwRouteModel.getList()) {
totalDuration += r.getDuration();
}
int addHH = totalDuration/60;
int addMM = totalDuration%60;
int addedHH = timeModel.getJam().getHH() + addHH;
int addedMM = timeModel.getJam().getMM() + addMM;
if (addedMM >= 60){
addedHH++;
addedMM -= 60;
}
output += addedHH;
output += ":";
output += addedMM;
return output;
}

public String getDepartureCityString(){
String output = "";
output += rwRouteModel.getRoute().getDeparture().getCityName();
return output;
}

public String getArrivalCityString(){
String output = "";
output += rwRouteModel.getRoute().getArrival().getCityName();
return output;
}

public String getTrainCodeString(){
return trainModel.getTrainCode();
}

public String getRemainingSeatString(){
String output = "";
int maxSeat = 0;
int filledSeat = 0;
for (CoachModel c : trainModel.getCoachs()) {
maxSeat += c.getSeatQty();
filledSeat += c.getSeat().size();
}
if (maxSeat > filledSeat){
output += "Sisa ";
output += maxSeat - filledSeat;
output += " kursi";
} else if (maxSeat == filledSeat){
output += "Full";
} else {
output += "Aneh";
}
return output;
}
}

0 comments on commit 1dbea00

Please sign in to comment.