编程辅导 C C++ Java Python MIPS Processing 网络家教 在线辅导

编程家教 远程写代码 Debug 讲解答疑 课后答疑 不是中介,本人直接答疑

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

 COMPSCI334 Assignment 1 1

COMPSCI334 Assignment 1The objective of this assignment is to practice the use of Java RMI technology. Thesystem to be developed consists of one server and several players. When the system isdeployed, the components are expected to be located at different sites.The system is a simplified networked Tic Tac Toe game. A Tic Tac Toe game is to beplayed between two players. Only registered users can use the system to play thegame. The server keeps information about the registered users. The informationshould include UPI and password of each user. The UPI should be used to identify auser uniquely. The server should also record the number of games that each user haswon, lost and drawn.When a player wants to play the game, the player must first log on the server. When aplayer logs in, the server provides the player with a list of players who are currentlyavailable to play a game. A player is available to play a game if the player has loggedon the server and is not playing a game with another player. A player can choose toplay a game with a player in the available players list. When two players agree to playwith each other, the two players interact with each other to play the game directlywithout the intervention of the server. When two players finish playing a game, theyshould be put back to the available players list and the server should update theinformation regarding the number of wins, loses and draws about the two playersaccording to the result of the game. The interactions between a player and the serverand the interaction between any two players should be carried out using Java RMI.Your assignment folder should have the following structure. The playerx folder holdsthe programs for player x. The server folder holds the server programs as well as thedatabase which stores the players’ information. For this assignment, you should havefive players.When the system is deployed, each folder corresponds to a machine (i.e. a site). Themachines are connected by a network.To make the marking of your assignment easier, you should NOT require the markerto upload class files (if any) to a web server before running your programs.Part 1 (10 points)On the server site, there is a database and programs for interacting with the database.The database contains a table 'users' which contains the registered users’ information.The table can be created with the SQL statement below.CREATE TABLE users (UPI char (7) NOT NULL CONSTRAINT tableConstraint PRIMARYKEY, password char (8) NULL, win int NULL, lose int NULL, draw int NULL)UPI is the UPI of a user. The meaning of the other columns should be obvious.Write a program called DBinit.java. The program should initialise the database on theserver. It should be assumed that the database is an MS Access database which isasgplayer1 playernplayer2 server…DocumentsPDFCompleteClick Here & UpgradeExpanded FeaturesUnlimited PagesCOMPSCI334 Assignment 1 2named as users.mdb. The file holding the initial data for populating the database is atext files which is named as USERS.CSV. The text file consists of several rows.Columns in a row are separated by “,” as shown below. The columns correspond tothe columns in the users table.player1,player1p,0,0,0player2,player2p,0,0,0player3,player3p,0,0,0player4,player4p,0,0,0player5,player5p,0,0,0Note: Your program should initialise the databases correctly regardless whether thedatabases are empty or not. In other words, DBinit can be executed multiple times.Part 2 (40 points)Write a program which allows a player log on the server. When a player logs insuccessfully, the server should provide a list of available players to the player. Theinterface for logging in and displaying available players list are shown below.Player Login InterfaceWhen a player starts his/her program, the following should be displayed:Figure 1When the “login” button is clicked, the information entered by the player should besent to the server. A login attempt is successful if the UPI and the password matchesthe corresponding information stored in a row in the database on the server. If a loginfails, the dialog panel below should be shown. The title of the panel must include theUPI of the player. If the “Yes” button is clicked, the login frame in Figure-1 should bedisplayed again. If the “No” button is clicked, the player’s program terminates.Player Information FrameIf a login is successful, a player information frame as below should be displayed:DocumentsPDFCompleteClick Here & UpgradeExpanded FeaturesUnlimited PagesCOMPSCI334 Assignment 1 3The title of the frame must include the UPI of the player. At the top of the frame, it isa table which shows the information about the players who are currently available. Inthis case, only one player, player1, has logged in. Therefore, only player1 appears inthe table. The combo box and the “select player” button will be explained in Part 3. Ifthe “quit” button is clicked, the player’s program terminates.Assume that another player, player2, has logged in successfully. After player2 loggedin successfully, the following frames should be seen by player1 and player2respectively.It should be noted that the table showing the available players in player1’s frame hasbeen automatically updated.Part 3 (20 points)You are required to improve the program in Part 2 to allow a player to select a playerin the available players list to play the tic tac toe game.The combo box in a player’s information frame should include all the availableplayers apart from the player himself/herself. A player uses the combo box to select aplayer. In this case, assume that player1 selects player2 to play. When the “selectplayer” button is clicked, the following dialog panel should be shown on the selectedplayer’s monitor.DocumentsPDFCompleteClick Here & UpgradeExpanded FeaturesUnlimited PagesCOMPSCI334 Assignment 1 4Note: The UPI of the player should appear in the title of the dialog panel.If player2 clicks “No” button, the dialog panel below should be shown to player1.If player2 clicks “Yes” button, a game board should be shown to each of the playersand the players’ information frames should disappear. The player who initiates thegame (i.e. player1 in this case) will use white stone and the player who accepts theinvitation (i.e. player2 in this case) will use black stone and move first. The followingfigure shows the game boards for player1 and player2 respectively.Note: The title of the board should display the UPI of the player. At the top of theboard, you should indicate whose turn it is now.When two players agree to play a game, they should be removed from the availableplayers list. For example, assume that a third player, player3, logs in before player1and player2 decide to play a game together. After logging in, player3’s informationframe should be as below:DocumentsPDFCompleteClick Here & UpgradeExpanded FeaturesUnlimited PagesCOMPSCI334 Assignment 1 5After player1 and player2 agree to play a game together, player3’s information frameshould be as below. It should be noted that the available players list and the combobox displaying the available players have been updated automatically.Note:· There are many possible scenarios regarding the timing of players invitingeach other to play a game. It is your job to consider all these scenarios andprovide a solution that works.· In this part, you are not required to implement the code for playing the tic tactoe game.Part 4 (30 points)In this part, you are required to write the code for playing the tic tac toe game. When agame is completed, the server should update the information about the two playersaccording to the result of the game.Assume that (a) three players, player1, player2 and player3, have logged on the server,(b) player1 and player2 have agreed to play a game, and (c) player1 uses white stoneand player2 uses black stone. The game boards seen by player1 and player2 are asbelow:Figure 2Your program should make sure that· A player can only place a stone on the game boards if it is the player’s turn.For example, in Figure-2, since it is player2’s turn, nothing happens if player1clicks on his/her game board.DocumentsPDFCompleteClick Here & UpgradeExpanded FeaturesUnlimited PagesCOMPSCI334 Assignment 1 6· When a player places a stone of his/her colour on the board, his/heropponent’s board should also be updated accordingly. Figure-3 shows theboards seen by player1 and player2 after player2 made his/her move. It shouldbe noted that the message regarding whose turn it is now is also updatedaccordingly.Figure 3· A player can only place a stone of his/her colour in a square which is stillempty on the boards. In Figure-3, if player1 clicks the black stone at the top-left corner, nothing happens.· When a game is finished, a dialog panel should be shown for each of theplayers to inform them the result of the game. Figure-4 shows the dialogpanels shown to player1 and player2 if the game is won by player1. Figure-5shows the dialog panels shown to player1 and player2 if the game is a draw.Figure 4Figure 5When a game is completed, the two players who played the game should be added toavailable players list again and they should be shown their information frames.Assume that player1 won the game. Figure-6 shows what the three players should seeafter the game. It should be noted that player1’s and player2’s information have beenupdated.DocumentsPDFCompleteClick Here & UpgradeExpanded FeaturesUnlimited PagesCOMPSCI334 Assignment 1 7Figure 6You should test your program for at least five players logging on the server at thesame time and at least two pairs of players playing games simultaneously.ReportYou should write a report which covers the following issues:· The parts that you have completed.· Detailed instructions on running your program. You should include a batchfile for running each of the components. [Note: It is important to provide asmuch details as possible. If your program cannot be executed by a marker, youwill NOT get any mark.]ResourcesYou can download Asg1Resource.zip at“http://www.cs.auckland.ac.nz/compsci334s1t/assignments/Asg1Resource.zip”. The“example” folder in the file contains a program that provides a GUI interface to ourAccount example discussed in our lectures. You might find that this example ishelpful for you to design the GUI interface for this assignment. The “TicTacToe”folder contains a program that implements a TicTacToe board that might be helpfulfor you to do this assignment. The “server” folder in the “Asg1” folder contains adatabase and a CSV files.DocumentsPDFCompleteClick Here & UpgradeExpanded FeaturesUnlimited PagesCOMPSCI334 Assignment 1 8SubmissionYou MUST thoroughly test your programs in Tamaki lab before you submit yourassignment. You should pack your programs into file Asg1.zip using a program likeWinZip. You should make sure that the directory structure is preserved. The filewhich contains your report should also be included in Asg1.zip. Name your report fileas “Report.doc”. You should submit file Asg1.zip through the assignment drop box.Total Points: 100 PointsDue Date: 23:59, 2nd April 2008, sharp.Electronic submission through the assignment drop box only.No email submission will be accepted.Appendix Tic-Tac-Toe RulesFor a player, the objective of Tic Tac Toe is to get three stones of the player in a row(the three stones can be in a vertical, horizontal, or, diagonal line). If none of theplayers manage to achieve the objective, the game is a draw.DocumentsPDFCompleteClick Here & UpgradeExpanded FeaturesUnlimited Pages

相关推荐