Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.util.*;
  2. public class Flight {
  3.  
  4. private ArrayList<Seat> seats;
  5. private Airport source;
  6. private Airport destination;
  7. private Date date;
  8. private int capacity;
  9. private int seatsLeft;
  10.  
  11. public Flight (ArrayList<Seat> seats, Airport source, Airport destination, Date date, int capacity) {
  12. this.seats = seats;
  13. this.source = source;
  14. this.destination = destination;
  15. this.date = date;
  16. this.capacity = capacity;
  17. seatsLeft = capacity;
  18. }
  19.  
  20. public ArrayList<Seat> getSeats() {
  21. return this.seats;
  22. }
  23.  
  24. public String getSource() {
  25. return this.source.toString();
  26. }
  27.  
  28. public String getDestination() {
  29. return this.source.toString();
  30. }
  31.  
  32. public Date getDate() {
  33. return this.date;
  34. }
  35.  
  36. public int getCapacity() {
  37. return this.capacity;
  38. }
  39.  
  40. public int getSeatsLeft() {
  41. return this.seatsLeft;
  42. }
  43.  
  44. public void seatsBought(int ticketsSold) {
  45. if (seatsLeft - ticketsSold >= 0) {
  46. seatsLeft = seatsLeft - ticketsSold;
  47. }
  48. else {
  49. System.out.println("Only " + seatsLeft + " left.");
  50. }
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement