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 recordpublic 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 CheckupRecordComplete a method to process a list of CheckupRecord. This method takes three parameters, an ArrayList, a current year and a current month. The method should return a list of equipment (just their IDs) whose last checkup date is one year or older from the specified current date. Assume curYear and curMonth represent a valid date.
public static ArrayList getEquipmentsToBeChecked( ArrayList records, int curYear, int curMonth) { // ADD CODE}For example, given an ArrayList with three records (shown in format of ID-year-month):
"104"-2019-7"114"-2018-5"124"-2019-9
Reference:
class java.util.ArrayListvoid add(int index, E element)boolean add(E element)E get(int index)boolean isEmpty()int size()
Step by Step Solution
There are 3 Steps involved in it
getEquipmentsToBeChecked method by iterating through the list of CheckupRecord objects checking if each records last checkup date is one year or older ... View full answer
Get step-by-step solutions from verified subject matter experts
