Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Air;
- import java.text.*;
- import java.util.Date;
- /**
- * Extension of CReport to represent Poor Quality Reports
- */
- class CPoorQualityReport extends CReport
- {
- private short recsNum = 2;
- //
- // default constructor
- //
- /**
- * Constructor for the CPoorQualityReport class.
- * <p>
- * Sets a header for the specific report.
- */
- public CPoorQualityReport ()
- {
- recsPerScreen = recsNum;
- printHeader = true;
- theHeader = " Poor Quality Report\n";
- }
- /**
- * Qualifies a flight record if the record has a special meal in the
- * report date range that was given a perceivedQuality value <5
- *
- * @param aFlightRecord current CFlightRecord object
- * @return Boolean value to determine if record qualifies
- */
- protected boolean qualifiesForReport (CFlightRecord aFlightRecord)
- //
- // qualifiesForReport qualifies a record for this report if it has a special meal loaded within the date
- // range of the report with a perceived quality less than 5
- //
- {
- int highQualityNum = 5;
- int lowQualityNum = 0;
- Date flightDate = aFlightRecord.getFlightDate();
- boolean checkFlightFromDate = (flightDate.after(fromDate) || flightDate.equals(fromDate));
- boolean checkFlightToDate = (flightDate.before(toDate) || flightDate.equals(toDate));
- boolean checkFlight = checkFlightFromDate && checkFlightToDate;
- boolean checkMeal = (aFlightRecord.getMealLoaded()
- && (aFlightRecord.getPerceivedQuality () < highQualityNum)
- && (aFlightRecord.getPerceivedQuality () >= lowQualityNum));
- return (checkFlight && checkMeal);
- } // qualifiesForReport
- /**
- * Outputs the passenger, flight date and meal type for a given record
- *
- * @param aFlightRecord current CFlightRecord object
- */
- protected void printRecord (CFlightRecord aFlightRecord)
- //
- // printRecord outputs the passenger, flight date, and meal type
- //
- {
- CPassenger tempPassenger = new CPassenger ();
- // represents the passenger assigned to
- // this reservation
- SimpleDateFormat flightDateFormat = new SimpleDateFormat ("MMM/dd/yyyy");
- // used to format dates
- if (tempPassenger.getPassenger (aFlightRecord.getPassengerID () ))
- {
- System.out.println ("-----------------------------------------------------------------------------\n");
- System.out.println ("PASSENGER: " + tempPassenger.toString ());
- System.out.println ("FLIGHT DATE: "
- + flightDateFormat.format (aFlightRecord.getFlightDate ())
- + " MEAL TYPE: "
- + CFlightRecord.mealTypeValues[aFlightRecord.getMealType ()
- - 'A']);
- }
- } // printRecord
- } // class CPoorQualityReport
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement