Project Deliverable 3 Personal Software Process Psp1 Javadoc Exception Handling

I need help with this assignment:

Project Deliverable 3 Personal Software Process (PSP1, JavaDoc, Exception Handling) Points: 50 —————————————————————————————————-

Instructions:

This assignment has to be completed by each student individually. NO COLLABORATION IS ALLOWED. Submit the following: YourASURiteID-ProjectDeliverable3.zip This compressed folder should contain the following files: 1. Connect4.java (Game Logic Module) 2. Connect4TextConsole.java (Console-based UI to test the game) 3. Connect4ComputerPlayer.java (logic to play against computer; generate computer moves) 4. JavaDoc documentation files (index.html and all other supporting files such as .css and .js files generated by the tool). Submit the entire folder. 5. Completed Time Log, Estimation worksheet, Design form, Defect Log, and Project Summary provided at the end of this assignment description 6. A few screen shots showing test results of your working game and answers to reflection questions written inline in this document 7. Readme file (optional: submit if you have any special instructions for testing)

—————————————————————————————————-

Connect4 Game: Connect4 is a 2-player turn-based game played on a vertical board that has seven hollow columns and six rows. Each column has a hole in the upper part of the board, where pieces are introduced. There is a window for every square, so that pieces can be seen from both sides. In short, it´s a vertical board with 42 windows distributed in 6 rows and 7 columns. Both players have a set of 21 thin pieces (like coins); each of them uses a different color. The board is empty at the start of the game. The aim for both players is to make a straight line of four own pieces; the line can be vertical, horizontal or diagonal.

Reference: https://en.wikipedia.org/wiki/Connect_Four —————————————————————————————————-

Program Requirements: To the previously developed Java-based Connect4 game, add a module to “play against the computer”. Can you take a look at my source code and give me a good starting point and help in how to finish it as a separate class called Connect4ComputerPlayer.java in the core package that generates the moves for the computer player. The logic to automatically generate computer moves does NOT have to be sophisticated AI algorithm. A naïve algorithm to generate the moves is sufficient for this assignment.

• Continue to make use of good Object-Oriented design • Provide documentation using Javadoc and appropriate comments in your code.

• Generate HTML documentation using Javadoc tool • Make sure you provide appropriate Exception Handling throughout the program (in the previously created classes as well)

Sample UI as shown in the figures below. 

| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Begin Game. Enter ‘P’ if you want to play against another player; enter ‘C’ to play against computer.

>>C

Start game against computer. It is your turn. Choose a column number from 1-7. 4 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |X| | | |

and so on..

—————————————————————————————————-

Personal Process: Follow a good personal process for implementing this game. You will be using PSP1 in this assignment. So, in addition to tracking your effort and defects you will have to estimate the effort and defects for the “play against computer” module as well as adding exception handling to previously created classes.

Here’s my code:

import java.util.Scanner;

 public class connect4

 {

   public static void main(String[] args)

   {

       Scanner in = new Scanner(System.in);

       char[][] grid = new char[6][7];

       for (int row = 0; row < grid.length; row++)

       {

           for (int col = 0; col < grid[0].length; col++)

           {

               grid[row][col] = ‘ ‘;

           }

       }

       int turn = 1;

       char player = ‘X’;

       boolean winner = false;     

       while (winner == false && turn <= 42)

       {

           boolean validPlay;

           int play;

           do {

               display(grid);

               System.out.print(“Player ” + player + “, Choose a column number from 1-7: “);

               play = in.nextInt();

               validPlay = validate(play,grid);

           }while (validPlay == false);

           for (int row = grid.length-1; row >= 0; row–)

           {

               if(grid[row][play] == ‘ ‘)

               {

                   grid[row][play] = player;

                   break;

               }

           }

           winner = isWinner(player,grid);

           if (player == ‘X’){

               player = ‘O’;

           }else{

               player = ‘X’;

           }

           turn++;         

       }

       display(grid);

       if (winner){

           if (player==’X’)

           {

               System.out.println(“Black won”);

           }else

           {

               System.out.println(“Red won”);

           }

       }else

       {

           System.out.println(“Tie game”);

       }

   }

   public static void display(char[][] grid)

   {

       System.out.println(” 0 1 2 3 4 5 6″);

       System.out.println(“—————“);

       for (int row = 0; row < grid.length; row++)

       {

           System.out.print(“|”);

           for (int col = 0; col < grid[0].length; col++)

           {

               System.out.print(grid[row][col]);

               System.out.print(“|”);

           }

           System.out.println();

           System.out.println(“—————“);

       }

       System.out.println(” 0 1 2 3 4 5 6″);

       System.out.println();

   }

   public static boolean validate(int column, char[][] grid)

   {

       if (column < 0 || column > grid[0].length)

       {

           return false;

       }

       if (grid[0][column] != ‘ ‘)

       {

           return false;

       }

       return true;

   }

   public static boolean isWinner(char player, char[][] grid)

   {

       for(int row = 0; row<grid.length; row++)

       {

           for (int col = 0;col < grid[0].length – 3;col++)

           {

               if (grid[row][col] == player  &&

                   grid[row][col+1] == player &&

                   grid[row][col+2] == player &&

                   grid[row][col+3] == player)

               {

                   return true;

               }

           }         

       }

       for(int row = 0; row < grid.length – 3; row++)

       {

           for(int col = 0; col < grid[0].length; col++)

           {

               if (grid[row][col] == player  &&

                   grid[row+1][col] == player &&

                   grid[row+2][col] == player &&

                   grid[row+3][col] == player)

               {

                   return true;

               }

           }

       }

       for(int row = 3; row < grid.length; row++)

       {

           for(int col = 0; col < grid[0].length – 3; col++)

           {

               if (grid[row][col] == player  &&

                   grid[row-1][col+1] == player &&

                   grid[row-2][col+2] == player &&

                   grid[row-3][col+3] == player)

               {

                   return true;

               }

           }

       }

       for(int row = 0; row < grid.length – 3; row++)

       {

           for(int col = 0; col < grid[0].length – 3; col++)

           {

               if (grid[row][col] == player  &&

                   grid[row+1][col+1] == player &&

                   grid[row+2][col+2] == player &&

                   grid[row+3][col+3] == player)

               {

                   return true;

               }

           }

       }

       return false;

   }

 }

Prof. Angela

4.6/5

Calculate Price


Price (USD)
$