Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Flight {
- private ArrayList<Seat> seats;
- private Airport source;
- private Airport destination;
- private Date date;
- private int capacity;
- private int seatsLeft;
- public Flight (ArrayList<Seat> seats, Airport source, Airport destination, Date date, int capacity) {
- this.seats = seats;
- this.source = source;
- this.destination = destination;
- this.date = date;
- this.capacity = capacity;
- seatsLeft = capacity;
- }
- public ArrayList<Seat> getSeats() {
- return this.seats;
- }
- public String getSource() {
- return this.source.toString();
- }
- public String getDestination() {
- return this.source.toString();
- }
- public Date getDate() {
- return this.date;
- }
- public int getCapacity() {
- return this.capacity;
- }
- public int getSeatsLeft() {
- return this.seatsLeft;
- }
- public void seatsBought(int ticketsSold) {
- if (seatsLeft - ticketsSold >= 0) {
- seatsLeft = seatsLeft - ticketsSold;
- }
- else {
- System.out.println("Only " + seatsLeft + " left.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement