- The learning objectives for this assignment are to gain experience with use of exceptions and file input and output. Using the code from Programming Assignment #2, you will modify the code to incorporate multiple uses of exceptions (listed below). In addition, you will revise the code to use input from a text file and write a log of the final results to a new file. The input file will provide the user choices of player name, difficulty level, and 4 room numbers. The choice to “run away” will no longer be used, since the input format must be predictable. Also, the choice of the player’s tool during the boss battle will be random rather than selected by input. A log of the input and correlating response/outcome will be written to a text file rather than displayed to a screen. You will be submitting both text files, java class files, and execution screenshots (showing the messages that result from exceptions). Make sure to demonstrate successful execution of the program and the responses for the exceptions.
Exceptions to be demonstrated:
1) At least 3 different existing Java exceptions
2) Use a try/catch block
3) Use of a throw statement
4) Create a custom exception that writes a useful error message to the displayMinimum validations requiring exceptions include:
1) matching input type: This error should allow the file to continue to be read after the delimiter. Specifically, you should incorporate a type mismatch in your input file and when the exception is generated, the code should display an error, but continue reading the file with the next input.
2) arithmetic errors: (ie. number out of expected range, number format types don’t match, overflow error, etc.) If this error does not fit for the way you designed your code (i.e. chance of escape, health below zero, etc.) then you may substitute this requirement with a different type of error.
3) file couldn’t be opened/read
4) couldn’t write to file