Java代写 | Project 2: TicTacToe

本次北美CS代写Java代写主要内容是要求使用Java Eclipse完成一个双人队长的Java游戏井字棋游戏代码编程。

Tic Tac Toe (50 points)
Write a class encapsulating the concept of a tic-tac-toe game as follows: (10 points) – class represents a player (20 points) – class represents the tictactoe board (20 points) – class that contains the logic of the game

  • Two players will be playing, player 1 and player 2. Each is an object of the Player class. Maintain the player’s name and the number of wins and losses they have accrued.
  • The board, TicTacToe class, is represented by a 2-dimensional array of 9 integer elements.
    • The value 0 in the array indicates that this place is available, the value 1 indicates the space is occupied by player 1 and the value 2 indicates that this space is occupied by player 2.
  • In the main method of your driver class, TicTacToeDriver, your program will simulate the tic-tac- toe game from the command line, doing the following:
    • Ask the players for the names.
    • Create a TicTacToe object and instantiate it.
    • Randomly designate who is player #1 and who is player #2.
    • In a loop, prompt for plays, as two integers (int row, int col), from the user. At each iteration of the loop, you will need to call methods of the TicTacToe class to update the TicTacToe object’s internal data. You need to keep track of who is playing (player 1 or 2), enforce the rules, check if either player has won the game.
    • If a player wins or there is a tie, you will need to exit the loop and present the result of the game.
  • In your TicTacToe class, make sure to implement:
    • a default constructor instantiating the array representing the board.
    • a method that allows a player to make a move. This method needs the player number and the position played on the board.
    • a method checking if a play is legal (the spot desired is not taken).
    • a method checking if a player has won the game; you should break up this method into several methods if the code involved is too long. (for instance, check if a player has won the game by claiming the entire horizontal row).
    • a method that checks whether the game is a tie (if no player has won and all the squares have been played, the game is tied).
    • an implementation of the public String toString() method that will return a String that displays the current visual representation of the board at any time during the game. Make sure to use ‘X’ and ‘O’ instead of 1 and 2.
  • BONUS:
    • Display the win/loss statistics of each player and allow players to play again if desired.


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:itcsdx