Page 1 of 1

RepairDept class Create a class called 'RepairDept' that manages components that are sent in for repair. It will hold an

Posted: Thu May 05, 2022 12:43 pm
by answerhappygod
Repairdept Class Create A Class Called Repairdept That Manages Components That Are Sent In For Repair It Will Hold An 1
Repairdept Class Create A Class Called Repairdept That Manages Components That Are Sent In For Repair It Will Hold An 1 (58.47 KiB) Viewed 31 times
RepairDept class Create a class called 'RepairDept' that manages components that are sent in for repair. It will hold an array of Component objects. Create the following members: • componentList - Array of Component objects. The components that are being diagnosed, repaired or shipped. partsOn Hand - Array of Part objects • nextPart - integer - index of next open slot in Parts array. If this matches maxParts, you must allocate more slots to the array (build a new array and copy the existing parts); • nextComponent-integer - index of next open slot in Components array. If this matches maxComponents, you must allocate more slots to the array (build a new array and copy the existing parts); • maxParts - int - Number of slots in the partsOnHand array • maxComponents - int - Number of slots in the componentList array Note, these do not need setters or getters but there will be methods to add a part to inventory, etc.
addComponent() public void addComponent(Component comp); This adds a component to the list and sets its state to 'waiting for diagnosis". If the component list is too small to handle a new part, you have to allocate a new list and copy the existing components. You can choose how many new slots to create. addPart() public void addPart(Part part); This adds a part to the list of parts in the shop. If the part list is too small to handle a new part, you have to allocate a new list and copy the existing parts. You can choose how many new slots to create. diagnose() public void diagnose(Component comp, String fail, String[] partsRequired); Indicates what caused the failure and what is needed for repair. Calls the component's diagnose() method to fill in the part list. It should look up each part (by the String part number supplied) in the parts On Hand array to verify there are enough parts. If there are insufficient parts to repair the unit, this sets the state to waitingForPart. If the parts are all in stock, sets the state to waiting For Repair. repair() public void repair(Component comp); Calls the repaired() method on the component which will set the component's state to waiting For Test. When a unit is repaired, this should go through the partsNeeded array, find each part in the parts inventory for the RepairDept, and decrement the countOnHand by 1. ship() public void ship(Component comp); Sets the components state to "shipped' components Waiting() public Component[] components Waiting() This returns a list of components waiting for diagnosis or repair (so active components that need attention). partArrived() public void partArrived(String partnumber, int count);
indicates which part arrived and how many. This method should call the addInventory () method in Part. findPart() public int findPart(String partnumber); This returns the index of the part in the parts list. If the part doesn't exist, it returns -1. That can be used to call methods on the part like addInventory() or decrementInventory (). dumpRepairDept() public void dumpRepairDept(); Finally, add a method, dump RepairDept() which will print out information on the list of components in the shop as well as the list of parts. You can use the various dump methods you wrote for the other classes to save effort. This will be used for debugging as you write more of the code for the system.