Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. package Air;
  2.  
  3. import java.text.*;
  4. import java.util.Date;
  5.  
  6. /**
  7. * Extension of CReport to represent Poor Quality Reports
  8. */
  9. class CPoorQualityReport extends CReport
  10. {
  11. private short recsNum = 2;
  12. //
  13. // default constructor
  14. //
  15. /**
  16. * Constructor for the CPoorQualityReport class.
  17. * <p>
  18. * Sets a header for the specific report.
  19. */
  20. public CPoorQualityReport ()
  21. {
  22. recsPerScreen = recsNum;
  23. printHeader = true;
  24. theHeader = " Poor Quality Report\n";
  25. }
  26.  
  27. /**
  28. * Qualifies a flight record if the record has a special meal in the
  29. * report date range that was given a perceivedQuality value <5
  30. *
  31. * @param aFlightRecord current CFlightRecord object
  32. * @return Boolean value to determine if record qualifies
  33. */
  34. protected boolean qualifiesForReport (CFlightRecord aFlightRecord)
  35. //
  36. // qualifiesForReport qualifies a record for this report if it has a special meal loaded within the date
  37. // range of the report with a perceived quality less than 5
  38. //
  39. {
  40. int highQualityNum = 5;
  41. int lowQualityNum = 0;
  42.  
  43. Date flightDate = aFlightRecord.getFlightDate();
  44.  
  45. boolean checkFlightFromDate = (flightDate.after(fromDate) || flightDate.equals(fromDate));
  46. boolean checkFlightToDate = (flightDate.before(toDate) || flightDate.equals(toDate));
  47.  
  48. boolean checkFlight = checkFlightFromDate && checkFlightToDate;
  49.  
  50. boolean checkMeal = (aFlightRecord.getMealLoaded()
  51. && (aFlightRecord.getPerceivedQuality () < highQualityNum)
  52. && (aFlightRecord.getPerceivedQuality () >= lowQualityNum));
  53.  
  54. return (checkFlight && checkMeal);
  55. } // qualifiesForReport
  56.  
  57. /**
  58. * Outputs the passenger, flight date and meal type for a given record
  59. *
  60. * @param aFlightRecord current CFlightRecord object
  61. */
  62. protected void printRecord (CFlightRecord aFlightRecord)
  63. //
  64. // printRecord outputs the passenger, flight date, and meal type
  65. //
  66. {
  67. CPassenger tempPassenger = new CPassenger ();
  68. // represents the passenger assigned to
  69. // this reservation
  70. SimpleDateFormat flightDateFormat = new SimpleDateFormat ("MMM/dd/yyyy");
  71. // used to format dates
  72.  
  73. if (tempPassenger.getPassenger (aFlightRecord.getPassengerID () ))
  74. {
  75. System.out.println ("-----------------------------------------------------------------------------\n");
  76. System.out.println ("PASSENGER: " + tempPassenger.toString ());
  77. System.out.println ("FLIGHT DATE: "
  78. + flightDateFormat.format (aFlightRecord.getFlightDate ())
  79. + " MEAL TYPE: "
  80. + CFlightRecord.mealTypeValues[aFlightRecord.getMealType ()
  81. - 'A']);
  82. }
  83. } // printRecord
  84. } // class CPoorQualityReport
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement