CS2133: Computer Science II Assignment 5 solution

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (2 votes)

1 Minesweeper revisited (30 points)
In this problem, we return to the Minesweeper game you wrote two assignments ago. First of all, if you did not get full credit on this question on Assignment 3, you have a chance to earn back some points here. Return to your code, now that we have gone over it and you have seen how to construct a working version using good MVC design. Refactor and fix it until you have a working game. This will net you half the points you lost on assignment 3. For this assignment, you will enhance your Minesweeper game with a couple of features. Add a menu bar to your JFrame, with a “File” menu. This menu should include four menu items: “New”, “Save”, “Load” and “Quit”.
• When a user selects “New”, the game should elicit information about how difficult the new game should be. Exactly how this works is up to you – specifying a gameboard size, odds of encountering a mine, or simply selecting a difficulty level. • “Save” should save the current game state to disk. Present the user with a file chooser dialog for specifying a name and place to save the game. Hint: If you have implemented the MVC architecture well, this should be only a couple of lines of code. • “Load”, by contrast, should load a saved game off the disk. Again, present the user with a file chooser. Handle the case where the user chooses a file that is not in fact a saved Minesweeper game. When the game has loaded, the board should look just like it did when the user saved it before. • “Quit” should simply end the program. The program should only quit when the user selects this option or clicks the JFrame’s close box. If the game is lost, the user should be able to look at the revealed game board and then select “New” to start again.
2 Your own webserver (35 points)
In Assignment 4, you wrote a simple web browser client. This time around, you will write a multithreaded webserver which will serve HTML files from the filesystem to a browser client. Write a program called Webserver.java that creates a ServerSocket object and then enters an infinite loop. The program should take the Socket returned by the ServerSocket’s accept() method, create a Runnable object that uses the Socket, pass this object to a Thread, start the Thread running, and go back to waiting for another client connection.
1
The Runnable object will handle establishing the connection and serving the file. You already know what the client’s handshake string looks like:
GET