Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

You must write a code to represent the game of Dots and Boxes, allowing two people to play. The code should be exceptionally well organized and very easy to follow. Variables, methods, and classes...

1 answer below »
You must write a code to represent the game of Dots and Boxes, allowing two people to play. The code should be exceptionally well organized and very easy to follow. Variables, methods, and classes should be named well. Arrays, loops, methods, & objects should be used anywhere they could reasonably be used. Each section of the program should be fully commented. Code should be written in Java format and simple language. I will attach a pdf textbook, material from chapters 1-7 should be used. Main focus should be on chapters 3-7.
Answered Same Day Dec 08, 2021

Solution

Ayush answered on Dec 11 2021
147 Votes
Dots and Boxes/Action.java
Dots and Boxes/Action.java
package com.example.dotsandboxes;   
   
import com.example.dotsandboxes.Boxes;   
import com.example.dotsandboxes.Player;   
     
public class Action {   
   
    private Player m_PlayerAction = null;   
    private boolean m_bChangePlayer = true;   
    private Box[][] m_Boxes = null;   
    private double m_dbValue = 0;   
       
    public Action(){   
        m_PlayerAction = null;   
        m_Boxes = null;   
        m_dbValue = 0;   
    }   
       
    /**  
     * 
copy
  
     *   
     * @param testAction  
     */   
    public Action(Action testAction) {   
        m_Boxes = new Box[testAction.m_Boxes.length][testAction.m_Boxes[0].length];   
           
        
 iterates over the matrix, creating the box   
        for(int i=0; i            for(int j=0; j                m_Boxes[i][j] = new Box(testAction.m_Boxes[i][j]);   
                   
                
 links the box to its top box, and vice-versa   
                if(i>0)   
                    m_Boxes[i][j].setTopBox(m_Boxes[i-1][j], true);   
                   
                
 links the box to its left box, and vice-versa   
                if(j>0)   
                    m_Boxes[i][j].setLeftBox(m_Boxes[i][j-1], true);   
            }   
        }          
        m_PlayerAction = new Player(testAction.m_PlayerAction);   
        m_dbValue = testAction.m_dbValue;   
        m_bChangePlayer = testAction.m_bChangePlayer;   
    }   
       
    public Box[][] getBoxes() {   
        return m_Boxes;   
    }   
    public double getValue() {   
        return m_dbValue;   
    }   
    public Player getPlayerAction() {   
        return m_PlayerAction;   
    }   
    public void setBoxes(Box[][] boxes) {   
        m_Boxes = boxes;   
    }   
    public void setValue(double value) {   
        m_dbValue = value;   
    }   
    public void setPlayerAction(Player playerAction) {   
        m_PlayerAction = playerAction;   
    }   
    public boolean isChangePlayer() {   
        return m_bChangePlayer;   
    }   
    public void setChangePlayer(boolean changePlayer) {   
        m_bChangePlayer = changePlayer;   
    }   
}   
 
Dots and Boxes/Boxes.java
Dots and...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here