Assignment title: Management
Question
ITECH2100/ITECH6100
Q
Download the provided zip file, extract it to your workspace, add the project to the
workspace, and look at the contents.
2. In particular, consider the file parts.txt which contains a set of records representing
computer parts or equipment that are for sale by the computer store.
The file's contents follow a specific format: The first line of the file is an int value,
specifying how many records will follow in the file after that line. Each of the records
consists of 3 separate lines. The first line of three for each record is the part's name, the
second line is the part's description, and the third line is the price of the part.
Programming 2, Lab 7 Page 2 of 3
The parts can be represented in the program by objects of the Part class type, which has been
provided to you. Ensure that you understand how to use the Part class.
3. Start to write a ComputerShop class that includes the features described below. Remember
that you will probably need to include exception handling code. As you come to each task,
you might want to update a separate Driver class (see task 4) to make sure it calls the
method, and tests that the method is working correctly:
a. The constructor of ComputerShop should create an ArrayList in which the parts will
all be stored. Initially (at constructor time) there should be no parts. Ensure that the
driver class creates an object of the ComputerShop type, which will be used for
calling the subsequent methods.
b. The loadPartsDataCleanly( ) method should replace any contents that are in the
ArrayList, with Part objects created from data which is read in from the parts.txt
file, and setting the quantity in stock to be initially 5 for each part. Ensure that your
driver class calls this method before any of the remaining methods or described
behaviour is done.
c. The showParts( ) method should display each of the Parts that the shop sells,
reporting all details of the parts including the quantity currently available.
d. The reportParts( ) method should do the same as for showParts( ) except the output
should be written to a text file named parts-report.txt
e. The addPart( ) method should accept a Part object reference as the parameter, and if
valid will store this part at the end of the ArrayList.
f. The savePartsBinary( ) method should save the current state of all parts that are in
the ArrayList (including any that have been added by task e), to a binary file named
parts.dat, using techniques for serialization. If you need to alter other code, this is
fine.