Project - Dots and Boxes
We're moving back in time, from the 1990's and Tetris, to the 1890's and the game of Dots and Boxes. This still-popular pencil-and-paper game can be found everywhere, from paper placemats and kids' menus in restaurants, to dozens of variants available for mobile and online play.

Once again you must develop an implementation of an interface. Your implementation will need to keep track of all aspects of the game. As in other projects, you'll be provided a few additional classes to assist with your implementation. The focus here is on somewhat advanced uses of collections, as well as on exception management. You have a lot of freedom here to design and develop your code in any way you see fit, so your guidance will be substantially more limited than in the past projects.

The interface is called edu.vt.cs5044.DotsAndBoxes and your implementation must be called edu.vt.cs5044.DABGame. You must of course create a test class as well, called edu.vt.cs5044.DABGameTest and achieve full code coverage. You are free to develop one or more additional helper classes, which you might find useful, but this is not required.

Getting Started
Start a new project in Eclipse, then import the files above exactly as you did with the files for the Tetris project. You'll need to use a lot of what you learned in that assignment to complete this assignment. Be sure to thoroughly review the API details for all the provided classes. Everything you need to know is in the API. There is no graphical interface, nor any other way to run your implementation beyond your test class, so a test-driven development strategy will be important to follow.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

package edu.vt.cs5044;

import java.util.*;

* DABGame class
public class DABGame implements DotsAndBoxes {

// Fields
private int size;
private Player currentPlayer;
private Map<Coordinate,Collection<Direction>> grid;
private Map<Coordinate,Player> owner;

// Initialize the grid for a new game
public void init(int size) {
if (size < 2)
throw new GameException();
// Set size field
this.size = size;
// Create a grid with no drawn edges
grid = new HashMap<Coordinate,Collection<Direction>>();
owner = new HashMap<Coordinate,Player>();
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {
Coordinate coord = new Coordinate(x, y);
grid.put(coord, new ArrayList<Direction>());
owner.put(coord, null);
// Reset all scores to zero
Map<Player,Integer> scores = new HashMap<Player,Integer>();
scores.put(Player.ONE, 0);...

By purchasing this solution you'll be able to access the following files:

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats