Assessment 9: Writing and Modifying Complex Programs
Instructions

This assessment is designed to be completed in fifty minutes or less. Your code must work on any valid inputs to receive credit.

Complete the template below such that you will provide code to solve the following problems. When you are satisfied with your solution, you should upload your solution to Marmoset. Marmoset will grade your solution within about a minute; you may modify your solution and resubmit while taking this assessment to get a higher score as necessary.

This final assessment will ask you to write and/or extend your project 5 solution.

You will have to do the following for this assignment:

You will be creating a PriceException class that extends the Exception class with the following methods. Later, you will modify your main method to use this class. Write the following methods for the PriceException class:
A constructor that takes a message as an argument. The constructor creates this attribute, and sets it to the incoming argument. The constructor also initializes an empty list of items.
A to-string method that can be called with str(...), which returns the message of the exception.

You will write a function called processFile:
You will write a function called processFile that takes as argument a filename, and opens that file and returns its contents, as a list of strings.

Finally, modify your main:
Take two arguments: the original argument of a list of strings, as well as a list of integers. The list of integers corresponds to how many items each shipment is allowed to have; if there are more items in the first argument than allowed by the second argument, the extra items are not included in that shipment and are discarded.

You may modify the classes you wrote as necessary.
Raise a PriceException (the new class you just wrote) when there is something wrong with just the price read in; otherwise, if the price is right (haha!) but the item is still wrong, continue to raise an ItemException.



Testing Your Code

Please log in to get access to the driver.

This driver already contains the tests, and will tell you which test number you're failing; look at the source code of the driver to see the details of that test. You can run the driver through the terminal with the command"

python driver.py

This will test your code on the same test cases as Marmoset, and give you a report. Once you've passed as many tests as you can, upload your submission to Marmoset using the instructions at the bottom of the page.


Code Templates


For this assessment there is no template to download; you will be using your own project5.py
Download the supporting file SystemCall for this assessment. Right-mouse click to save the file as SystemCall.java.

Download the supporting file code supporting file for this assessment. Right-mouse click and save the file as code.py.


You may also refer to the template for writing classes.

Submission Instructions

Upload your files called project5.py, SystemCall.java, data.txt, and code.py to Marmoset using the link to assessment9_sample. Make sure you click the correct link, as there are ten versions of this assessment, and your answers will only work for one of them.

See the instructions below to walk you through how to upload a file to Marmoset.

[Marmoset upload help] (opens in new window)