CS1331 Homework 6 - EXTRA CREDIT - Exceptions

HW6 Files

Introduction

This is an extra credit homework worth up to 30 points. The points you earn will be added to your Homework 3 grade. This assignment is optional and you will NOT be penalized for not completing it. It is due Sunday, July 2 at 11:55 pm and late submissions will NOT be accepted.

This assignment will involve Exceptions.

Description

You are charged with helping a restaurant implement electronic ordering. You have access to a food database, as represented by the file Food.txt. You also have access to a drink database, as represented by the file Drink.txt. You will prompt the customer to enter their food item, and then their drink item. If the user enters a food item that does not exist, but their drink exists, you must generate a FoodNotFoundException, a custom exception that you will build. If the user enters a drink item that does not exist, but their food exists, you must generate a custom DrinkNotFoundException. If both their food and drink selections do not exist, you must generate a custom FoodAndDrinkNotFoundException. All of your exceptions must be CHECKED EXCEPTIONS. If the user generates any of these exceptions, your program should not crash, but rather it should ask them again to enter their food and drink selections.

Provided Files and Solution Description

You will have to create the files Restaurant.java, FoodNotFoundException.java, DrinkNotFoundException.java, and FoodAndDrinkNotFoundException.java.

Restaurant.java

This class contains the following methods.

FoodNotFoundException.java, DrinkNotFoundException.java, FoodAndDrinkNotFoundException.java

These are CHECKED exceptions. For each Exception, implement a one argument constructor that takes in an error message as a String and properly sets the message. Hint: When the getMessage method is called on any of these exceptions it should return the error message.

Food.txt, Drinks.txt

These files have been provided for you. They contain foods and drinks that the restaurant offers. The format will be as follows, where each line contains a separate item:

fajita
burrito
quesadilla

Tips

Compiling and Testing Your Code

To compile your code simply run javac *.java from the directory in which your java and text files are located. Run java Restaurant Food.txt Drinks.txt in order to test your code. You can look through the text files to see which foods and drinks exist. Try entering various combinations of correct and incorrect foods and drinks, and see if the appropriate error messages print out.

Javadocs

Checkstyle

You must run checkstyle on your submission. The checkstyle cap for this submission is 30 points.

Run checkstyle for this assignment with java -jar checkstyle-6.2.2.jar -a *.java. This will check for both checkstyle errors and javadoc errors.

Collaboration with other students

When completing homeworks for CS1331 you may talk with other students about:

You may not discuss, show, or share by other means the specifics of your code, including screenshots, file sharing, or showing someone else the code on your computer, or use code shared by others.

Examples of approved/disapproved collaboration:

Collaborating with others in a way that violates the approved means is a Georgia Tech Honor Code violation.

Turn-in Procedure

YOUR SUBMISSION SHOULD ONLY CONTAIN .JAVA FILES!

Compress the hw6 files into a .zip file and submit that on T-square. Make sure the zip file contains Restaurant.java, FoodNotFoundException.java, DrinkNotFoundException.java, and FoodAndDrinkNotFoundException.java. Do NOT submit your .class files.

Verify the Success of Your Submission to T-Square

Practice safe submission! Verify that your HW files were truly submitted correctly, the upload was successful, and that your program runs with no syntax or runtime errors. It is solely your responsibility to turn in your homework and practice this safe submission safeguard.