This page lists the milestone requirements for Milestone 11 of the CC 410 Restaurant Project. Read the requirements carefully and discuss any questions with the instructors or TAs.
The CC 410 Restaurant Project project for this semester is centered around building a point of sale (POS) system for a fictional restaurant named Starfleet Subs, based in the Star Trek universe.
The eleventh milestone involves adding form validation and serialization to the existing project, specifically targeted at custom menu items.
This milestone must follow these professional coding standards:
__init__.py
and __main__.py
are exempt.application
plugin. The project should compile without errors.starfleetsubs.gui
package do not require type hints in Python, though you may continue to use them if they are helpful. Any errors from Mypy originating in these classes will be ignored.flake8-docstrings
and pep8-naming
plugins. Code should conform to PEP 8 style with Google style docstrings.This milestone consists of two portions: adding form validation to the forms for creating and editing custom items, and serializing those custom items to a file.
Update the forms for creating and editing custom menu items to perform server-side validation. This should use the built-in features of either Java Spring or Python Flask, as demonstrated in the example video. The following validation rules should be enforced:
name
of the custom menu item should not be null, and have at least 3 characters.price
of the custom menu item must be greater than or equal to 0, and support no more than 2 decimal places. You may either use a validator for this or implement rounding in the setter for this item.calories
of the custom menu item must be greater than or equal to 0.When validation fails, the user should be taken back to the form, where the entered values are still present and the validation errors are clearly displayed.
Tip
Java developers will need to change the price
attribute to use the BigDecimal
class (Javadoc) in order to enforce a limit on the number of digits using a validator. I recommend maintaining the existing getter and setters for price
(adapting them to use the value in the new BigDecimal
class) and then adding new getters and setters for this attribute. Likewise, in the HTML form, you’ll use the new BigDecimal
attribute instead of the existing price
. See the example video for details.
Update the application to use serialization to store and load the list of custom items. You may choose any file format (XML, JSON, or binary, or another of your choosing). See the serialization examples on GitHub (Java or Python) as well as the textbook for code you can use.
CustomItemList
class is created. In Java, this would most likely be the getInstance()
method, while in Python it would be in the __new__()
method. So, when the user first visits the /customitems
page, the previously saved custom items should appear.CustomItemList
class should implement a new method called save
that will serialize the current contents of the custom item list to a file.CustomItemController
with the path /customitems/save
that will save the existing custom items list to file by calling the new save
method./customitems
index page containing a button to save the custom items by sending a POST request to the new route. This form will be very similar to the one used on the page for deleting items.The code should include proper exception handling when reading and writing files, as well as ensuring the file is properly closed. In Java, a try with resources statement is recommended. In Python, a with inside a try structure is recommended. You may simply catch the generic exception and print it to the terminal instead of handling multiple exception types.
As proof of working serialization, create the following custom menu item and serialize it to a file, then ensure that file is committed to your Git repository when committing this project.
Completing this project is estimated to require 2 - 5 hours.
Tip
A rough estimate for this milestone would be around 100 lines of new or updated code.-Russ
This assignment will be graded based on the rubric below:
The following deductions apply:
This is not an exhaustive list of possible deductions. The instructors will strive to provide reasonable and fair grading, but we can’t predict all possible defects. It is up to the student to ensure that the project is complete and correct before submission.
Submit this assignment by creating a release on GitHub and uploading the release URL to the assignment on Canvas. You should not submit this Codio project or mark it as complete in Codio, in case you need to come back to it and make changes later.