Question: A software used by engineers uses a CheckupRecord class to record equipment checkup information. For simplicity, only equipment id, last checkup date and relevant methods
A software used by engineers uses a CheckupRecord class to record equipment checkup information. For simplicity, only equipment id, last checkup date and relevant methods of this class are shown here:
// A class for equipment checkup record public class CheckupRecord { private String eId; // equipment ID private int monthOfLastCheckup; // 1 - 12 private int yearOfLastCheckup; // a valid year // additional data/methods not shown public String getEId() { return eId; } public int getMonthOfLastCheckup() { return monthOfLastCheckup; } public int getYearOfLastCheckup() { return yearOfLastCheckup; } } // end class CheckupRecord
Complete a method to process a list of CheckupRecord. This method takes three parameters, an ArrayList
public static ArrayListgetEquipmentsToBeChecked( ArrayList records, int curYear, int curMonth) { // ADD CODE }
For example, given an ArrayList
"104"2019-7 "114"2018-5 "124"2019-9
and different curMonth and curYear values, the method should work like this:
| return | note | |
2020, 7 | {"104", "114"} | "104"-2019-7: exactly one year ago; "114"-2018-5: more than one year ago; "124"-2019-9: not one year yet. | |
2019, 12 | {"114"} | "104"-2019-7: not one year yet; "114"-2018-5: more than one year ago; "124"-2019-9: not one year yet. | |
2019, 8 | {"114"} | Dont worry about why current date is older than some last checkup dates. You just need to compare the dates to see if last checkup date is one year ago or older. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
