forked from Alpro-Kelompok-4/ticket-com
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
439 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"cityCode":"BDG","cityName":"BANDUNG"}] | ||
[{"cityCode":"BDG","cityName":"BANDUNG"},{"cityCode":null,"cityName":"BDG"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"route":{"departure":{"cityCode":"JKT","cityName":"Jakarta"},"arrival":{"cityCode":"BDG","cityName":"Bandung"},"routeCode":"JKT-BDG","business":{"price":30000.0},"premium":{"price":20000.0}},"rwRouteCode":"JL01","list":[{"origin":{"rwStationCode":"GMB","rwStationName":"Gambir"},"destination":{"rwStationCode":"JTR","rwStationName":"Jatinegara"},"duration":30},{"origin":{"rwStationCode":"JTR","rwStationName":"Jatinegara"},"destination":{"rwStationCode":"BKS","rwStationName":"Bekasi"},"duration":30}],"sumOfDuration":60}] | ||
[{"route":{"departure":{"cityCode":"JKT","cityName":"Jakarta"},"arrival":{"cityCode":"BDG","cityName":"Bandung"},"routeCode":"JKT-BDG","business":{"price":30000.0},"premium":{"price":20000.0}},"rwRouteCode":"JL01","list":[{"origin":{"rwStationCode":"GMB","rwStationName":"Gambir"},"destination":{"rwStationCode":"JTR","rwStationName":"Jatinegara"},"duration":30},{"origin":{"rwStationCode":"JTR","rwStationName":"Jatinegara"},"destination":{"rwStationCode":"BKS","rwStationName":"Bekasi"},"duration":30}],"sumOfDuration":60},{"route":{"departure":{"cityCode":"BDG","cityName":"Bandung"},"arrival":{"cityCode":"JKT","cityName":"Jakarta"},"routeCode":"BDG-JKT","business":{"price":30000.0},"premium":{"price":20000.0}},"rwRouteCode":"JL02","list":[{"origin":{"rwStationCode":"KAC","rwStationName":"Kiaracondong"},"destination":{"rwStationCode":"CMH","rwStationName":"Cimahi"},"duration":40},{"origin":{"rwStationCode":"JTN","rwStationName":"Jatinegara"},"destination":{"rwStationCode":"GMB","rwStationName":"Gambir"},"duration":30}],"sumOfDuration":70}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1 @@ | ||
[{ | ||
"rwStationCode": "GMB", | ||
"rwStationName": "Gambir" | ||
}, { | ||
"rwStationCode": "JTN", | ||
"rwStationName": "Jatinegara" | ||
}, { | ||
"rwStationCode": "BDN", | ||
"rwStationName": "Bandung" | ||
}, { | ||
"rwStationCode": "CMH", | ||
"rwStationName": "Cimahi" | ||
}, { | ||
"rwStationCode": "KAC", | ||
"rwStationName": "Kiaracondong" | ||
}, { | ||
"rwStationCode": "SGU", | ||
"rwStationName": "Surabaya Gubeng" | ||
} | ||
] | ||
[{"rwStationCode":"GMB","rwStationName":"Gambir"},{"rwStationCode":"JTN","rwStationName":"Jatinegara"},{"rwStationCode":"CMH","rwStationName":"Cimahi"},{"rwStationCode":"KAC","rwStationName":"Kiaracondong"},{"rwStationCode":"SGU","rwStationName":"GUBENG"},{"rwStationCode":"BDG","rwStationName":"BANDUNG"}] |
51 changes: 46 additions & 5 deletions
51
src/main/java/org/kelompok4/app/Controller/ReportController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,73 @@ | ||
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 BookingController bookingController; | ||
//private TrainScheduleModel trainScheduleModel; | ||
private ReportView reportView; | ||
|
||
|
||
public ReportController(BookingController bookingController, ReportView reportView) { | ||
this.bookingController = bookingController; | ||
this.reportView = reportView; | ||
} | ||
|
||
public ReportController() { | ||
this.bookingController = new BookingController(); | ||
this.reportView = new ReportView(); | ||
} | ||
|
||
@Override | ||
public void read() { | ||
|
||
} | ||
|
||
|
||
|
||
//unsolid | ||
/** | ||
* Bentuk belum SOLID | ||
*/ | ||
public void showDailyReport() { | ||
|
||
//data pemasukan harian | ||
reportView.printHeaderDailyReport(); | ||
//total masukan harian | ||
reportView.printDailyReportPage(); | ||
/** | ||
* Masukin json kumpulan booking yang sudah paid | ||
* dalam rentang satu hari | ||
*/ | ||
bookingController.getTotalPayment(); | ||
} | ||
|
||
public void showMonthlyReport() { | ||
//laporan bulanan pemasukan | ||
reportView.printMonthlyReportPage(); | ||
//data pemasukan bulanan | ||
reportView.printHeaderMonthlyReport(); | ||
//total masukan bulanan | ||
reportView.printTotalMonthlyReport(); | ||
/** | ||
* Masukin json kumpulan booking yang sudah paid | ||
* dalam rentang satu bulan | ||
*/ | ||
bookingController.getTotalPayment(); | ||
|
||
} | ||
|
||
public void showAnnualReport() { | ||
//laporan tahunan pemasukan | ||
reportView.printAnnualReportPage(); | ||
//data pemasukan tahunan | ||
reportView.printHeaderAnualReport(); | ||
//total pemasukan tahunan | ||
reportView.printTotalAnualReport(); | ||
/** | ||
* Masukin json kumpulan booking yang sudah paid | ||
* dalam rentang satu tahun | ||
*/ | ||
bookingController.getTotalPayment(); | ||
|
||
|
||
} | ||
} |
190 changes: 190 additions & 0 deletions
190
src/main/java/org/kelompok4/app/Controller/RwStationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.kelompok4.app.Controller; | ||
|
||
import com.github.freva.asciitable.AsciiTable; | ||
import com.github.freva.asciitable.Column; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import org.kelompok4.app.Interface.ICanCreate; | ||
import org.kelompok4.app.Interface.ICanDelete; | ||
import org.kelompok4.app.Interface.ICanRead; | ||
import org.kelompok4.app.Interface.ICanUpdate; | ||
import org.kelompok4.app.Interface.ICanValidateName; | ||
import org.kelompok4.app.Interface.ICanManageRwStation; | ||
import org.kelompok4.app.Model.RwStationModel; | ||
import org.kelompok4.app.Repo.RwStationRepo; | ||
import org.kelompok4.app.View.RwStationView; | ||
|
||
/** | ||
* | ||
* | ||
*/ | ||
public class RwStationController implements ICanCreate,ICanRead,ICanUpdate,ICanValidateName,ICanDelete, ICanManageRwStation{ | ||
private RwStationModel rwStationModel; | ||
private RwStationView rwStationView; | ||
private RwStationRepo rwStationRepo = new RwStationRepo(); | ||
public RwStationController(RwStationModel rwStationModel, RwStationView rwStationView) { | ||
this.rwStationModel = rwStationModel; | ||
this.rwStationView = rwStationView; | ||
} | ||
|
||
public RwStationModel getRwStationModel() { | ||
return rwStationModel; | ||
} | ||
|
||
public void setRwStationModel(RwStationModel rwStationModel) { | ||
this.rwStationModel = rwStationModel; | ||
} | ||
|
||
public RwStationView getRwStationView() { | ||
return rwStationView; | ||
} | ||
|
||
public void setRwStationView(RwStationView rwStationView) { | ||
this.rwStationView = rwStationView; | ||
} | ||
|
||
@Override | ||
public void create() { | ||
rwStationRepo.create(rwStationModel); | ||
} | ||
|
||
@Override | ||
public void read() { | ||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. | ||
} | ||
|
||
@Override | ||
public void update() { | ||
rwStationRepo.update(rwStationModel); | ||
} | ||
|
||
@Override | ||
public boolean validateName() { | ||
return ICanValidateName.NAME_REGEX.matcher(getRwStationName()).find(); | ||
} | ||
|
||
@Override | ||
public String getRwStationCode() { | ||
return rwStationModel.getRwStationCode(); | ||
} | ||
|
||
@Override | ||
public void setRwStationCode(String rwStationCode) { | ||
rwStationModel.setRwStationCode(rwStationCode); | ||
} | ||
|
||
@Override | ||
public String getRwStationName() { | ||
return rwStationModel.getRwStationName(); | ||
} | ||
|
||
@Override | ||
public void setRwStationName(String rwStationName) { | ||
rwStationModel.setRwStationCode(rwStationName); | ||
} | ||
public void addStationView(){ | ||
rwStationView.printAddStationPage(); | ||
rwStationView.printAddStation(); | ||
} | ||
|
||
public void editStationView(){ | ||
rwStationView.printEditStationPage(); | ||
rwStationView.printEditStation(); | ||
} | ||
|
||
public void showStationView(){ | ||
rwStationView.printViewStationPage(); | ||
} | ||
|
||
public void deleteStationView(){ | ||
rwStationView.printDeleteStationPage(); | ||
rwStationView.printDeleteStation(); | ||
} | ||
public boolean validateCodeStation(){ | ||
RwStationModel rwStationModel = rwStationRepo.get(this.getRwStationCode()); | ||
if(rwStationModel.getRwStationCode()== null){ | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
public boolean validateUpdateDeleteCodeStation(){ | ||
RwStationModel rwStationModel = rwStationRepo.get(this.getRwStationCode()); | ||
if(rwStationModel.getRwStationCode()!= null){ | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
public ArrayList<RwStationModel> fetchAll(){ | ||
return rwStationRepo.getAll(); | ||
} | ||
public String allRwStationView(ArrayList<RwStationModel> rwStationModels){ | ||
return AsciiTable.getTable(rwStationModels, Arrays.asList( | ||
new Column().header("KODE STASIUN").with(rwStationModel ->rwStationModel.getRwStationCode()), | ||
new Column().header("NAMA STASIUN").with(rwStationModel ->rwStationModel.getRwStationName()))); | ||
} | ||
public void resultView(){ | ||
rwStationView.printRwStationCode(getRwStationCode()); | ||
rwStationView.printRwStationName(getRwStationName()); | ||
} | ||
public void resultAddRwStation(boolean success){ | ||
if(success){ | ||
rwStationView.SuccessAddStation(); | ||
}else { | ||
rwStationView.FailedAddStation(); | ||
} | ||
} | ||
public void resultEditStation(boolean success){ | ||
if(success){ | ||
rwStationView.SuccessEditStation(); | ||
}else { | ||
rwStationView.FailedEditStation(); | ||
} | ||
} | ||
|
||
public void resultDeleteStation(boolean success){ | ||
if(success){ | ||
rwStationView.SuccessDeleteStation(); | ||
}else { | ||
rwStationView.FailedDeleteStation(); | ||
} | ||
} | ||
|
||
public void stationTable(String S){ | ||
rwStationView.printShowTable(S);; | ||
} | ||
|
||
public boolean validateInputStation(String input) { | ||
boolean valid; | ||
String[] inputs=input.split("\\s+"); | ||
if(inputs.length==2){ | ||
if(inputs[0].length()==3){ | ||
rwStationModel.setRwStationCode(inputs[0]); | ||
valid=true; | ||
}else { | ||
valid=false; | ||
} | ||
rwStationModel.setRwStationName(inputs[1]); | ||
if (validateName()){ | ||
valid=true; | ||
}else { | ||
valid=false; | ||
} | ||
}else { | ||
valid=false; | ||
} | ||
return valid; | ||
} | ||
|
||
@Override | ||
public void delete() { | ||
setRwStationModel(rwStationRepo.get(getRwStationCode())); | ||
rwStationRepo.delete(rwStationModel); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/kelompok4/app/Interface/ICanManageRwStation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.kelompok4.app.Interface; | ||
|
||
/** | ||
* | ||
* @author Rewingw | ||
*/ | ||
public interface ICanManageRwStation { | ||
public String getRwStationCode(); | ||
public void setRwStationCode(String rwStationCode); | ||
public String getRwStationName(); | ||
public void setRwStationName(String rwStationName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.