Story 9 functionality added.
This commit is contained in:
@@ -72,6 +72,7 @@ public class SharedTripsController extends Controller{
|
||||
popUpGrid.addRow(0);//car color
|
||||
popUpGrid.addRow(0);//car year
|
||||
popUpGrid.addRow(0);//car performance
|
||||
popUpGrid.addRow(0);//book button
|
||||
|
||||
//information
|
||||
Label tripTitle = new Label(trip.name);
|
||||
@@ -121,13 +122,23 @@ public class SharedTripsController extends Controller{
|
||||
|
||||
stopTableView.setItems(trip.route);
|
||||
|
||||
popUpGrid.add(stopTableView, 1, 1, 1, 8);
|
||||
popUpGrid.add(stopTableView, 1, 1, 1, 9);
|
||||
|
||||
AnchorPane.setTopAnchor(popUpGrid, 0.0);
|
||||
AnchorPane.setBottomAnchor(popUpGrid, 0.0);
|
||||
AnchorPane.setRightAnchor(popUpGrid, 0.0);
|
||||
AnchorPane.setLeftAnchor(popUpGrid, 0.0);
|
||||
|
||||
//book button
|
||||
Button bookRide = new Button("Book Ride");
|
||||
bookRide.setOnAction(e->{
|
||||
trip.bookSeat(parent.getSession().getUserCode());
|
||||
tripDetails.close();
|
||||
search();
|
||||
popUp(Alert.AlertType.CONFIRMATION, "Success!", "You have Successfully booked a ride!", "The ride has been successfully booked and can be viewed in your booked rides.");
|
||||
});
|
||||
popUpGrid.add(bookRide, 0, 10, 2, 1);
|
||||
|
||||
wrapper.getChildren().add(popUpGrid);
|
||||
|
||||
Scene detailsScene = new Scene(wrapper);
|
||||
@@ -149,8 +160,11 @@ public class SharedTripsController extends Controller{
|
||||
boolean ignoreStopSearch = ignoreStopFilter && ignoreStopNameSearch;
|
||||
Pattern stopNamePattern = Pattern.compile(".*"+stopName.getText()+".*", Pattern.CASE_INSENSITIVE);
|
||||
//ignore direction
|
||||
boolean ignoreDirection = directionBox.getSelectionModel().isSelected(0);
|
||||
boolean ignoreDirection = directionBox.getSelectionModel().isSelected(0) || directionBox.getValue() == null;
|
||||
for(SharedTrip sharedTrip: parent.getSession().getDataManager().getSharedTrips()){
|
||||
if (sharedTrip.isFull()){
|
||||
continue;
|
||||
}
|
||||
//stops are equal
|
||||
boolean add = false;
|
||||
for (TripStop stop : sharedTrip.route) {
|
||||
|
||||
@@ -7,8 +7,11 @@ public class SharedTrip extends Trip {
|
||||
|
||||
private int seatsAvailable;
|
||||
|
||||
private String[] userBookings;
|
||||
|
||||
public SharedTrip (Trip trip, int seatsAvailable){
|
||||
super(trip.name, trip.route, trip.direction, trip.ride, trip.days, trip.reoccur, trip.endDate);
|
||||
userBookings = new String[this.ride.getNumSeats() - 1];
|
||||
this.seatsAvailable = seatsAvailable;
|
||||
}
|
||||
|
||||
@@ -29,7 +32,13 @@ public class SharedTrip extends Trip {
|
||||
return seatsAvailable;
|
||||
}
|
||||
|
||||
public void setSeatsAvailable(int seatsAvailable) {
|
||||
this.seatsAvailable = seatsAvailable;
|
||||
public void bookSeat(String user){
|
||||
userBookings[ride.getNumSeats() - seatsAvailable - 1] = user;
|
||||
seatsAvailable -= 1;
|
||||
}
|
||||
|
||||
public boolean isFull(){
|
||||
return seatsAvailable == 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user