✓ Kizspy.me Questions: (10 marks)
The given files already contain statements to implement a program for managing a House
moving process. The structure of the main classes is as follows:
•
Class Item: contains information about a furniture item, including:
•
.
°
name (e.g., "Table", "Chair", "Sofa")
。 weight (must be > 0, representing the weight of the item in kg)
。 length (must be > 0, indicating the number of meters the item occupies)
。 fragile is 1 (if the Item is fragile), or 0 (if this is not fragile)
Class Node: includes info (a Item object) and next (a pointer for linking).
Class ItemList: is a singly linked list that manages regular Nodes with complete
information about the furniture in the house.
•
Class Truck: is a stack structure (implemented as a linked list) where the info of the
Nodes contains the furniture items loaded onto the truck. Stack has FIFO properties, the
stack in this test is built using a singly linked list, the item is pushed to the head.
•
Class House: is the main class of the program, containing a ItemList used to manage the
furniture in a ItemList and a Truck corresponding to the truck transporting furniture.
Students are required to carefully read the provided code segments to fully understand the
relationships between the classes and the functions within each class. The specific task of the
test is to execute the following requirements:
a. f1(): 2.5 marks - Load data
To complete the requirement f1(), students need to:
1. Implement the function addLast(String name, int weight, int length, int fragile) in the
ItemList class-list
2. Implement the function push(String name, int weight, int length, int fragile) in the Truck
class - truck
Zoom
- FUO
+ 100%
Close