Problem

Modify the world-of-zuul project so that it writes a script of user input to a text file...

Modify the world-of-zuul project so that it writes a script of user input to a text file as a record of the game. There are several different ways that you might think of tackling this:

• You could modify the Parser class to store each line of input in a list and then write out the list at the end of the game. This will produce a solution that is closest to the basic pattern we have outlined in the discussion above.

• You could place all of the file handling in the Parser class so that, as each line is read, it is written out immediately in exactly the same form as it was read. File opening, writing, and closing will all be separated in time from one another (or would it make sense to open, write, and then close the file for every line that is written?).

• You could place the file handling in the Game class and implement a toString method in the Command class to return the String to be written for each command.

Consider each of these possible solutions in terms of responsibility-driven design and the handling of exceptions, along with the likely implications for playing the game if it proves impossible to write the script. How can you ensure that the script file is always closed when the end of the game is reached? This is important to ensure that all of the output is actually written to the external file system.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT