Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this programming project, you and your partner will be writing a Java application that implements a board game that uses derived classes from an

For this programming project, you and your partner will be writing a Java application that implements a board game that uses derived classes from an abstract class that represents a space on the game board. You are required to write the following classes:

  1. This should be an abstract class with one or more abstract methods. The class should at least have one abstract method called onLanding() that returns the adjustment on the players new position based on the type of the space.
  2. Derived classes from BoardSpace that represents different types of board spaces.
  3. A class that has at least one instance variable that represents a players position on the board.
  4. The Java application the implements the game. The game board should be instantiated and populated with the various types of board spaces defined in (2). The game board spaces may be statically or dynamically defined, depending on the board game you are implementing.

You may use the provided Die class that represents a six-sided game die.

public class Die{

private final int MAX = 6; // maximum face value

private int faceValue; // current value showing on the die

//-----------------------------------------------------------------

// Constructor: Sets the initial face value.

//-----------------------------------------------------------------

public Die() {

faceValue = 1;

}

//----------------------------------------------------------------- //

Rolls the die and returns the result.

//-----------------------------------------------------------------

public int roll() { f

aceValue = (int)(Math.random() * MAX) + 1;

return faceValue;

}

//-----------------------------------------------------------------

// Face value mutator.

//-----------------------------------------------------------------

public void setFaceValue (int value) {

faceValue = value;

}

//-----------------------------------------------------------------

// Face value accessor.

//-----------------------------------------------------------------

public int getFaceValue() {

return faceValue;

} //-----------------------------------------------------------------

// Returns a string representation of this die.

//-----------------------------------------------------------------

public String toString() {

String result = Integer.toString(faceValue);

return result;

}

}

Rules of the Game of the Goose (Links to an external site.):

Description by Dagonell the Juggler

The game was invented for Francesco de Medici, who gave it to Phillip II of Spain. Any number of players may participate, however more than six tends to be impractical. It is strictly a game of chance and children can compete on an equal basis with adults.

The board is a spiral race course with both reward and penalty squares. Players advance by rolling dice and moving their marker that number of spaces. First player to arrive at the center, square sixty-three (63), by exact count wins. If the final dice roll is too high, the player must move his piece forward to the last square and then backwards until the full count is reached.

Only one player may occupy any space on the board. If you end your turn on a square occupied by an opponent, that player goes back to the square you started your turn from.

The following squares have a Goose on them:

  • five (5)
  • nine (9)
  • fourteen (14)
  • eighteen (18)
  • twenty-three (23)
  • twenty-seven (27)
  • thirty-two (32),
  • thirty-six (36)
  • forty-one (41)
  • forty-five (45)
  • fifty (50)
  • fifty-four (54) and
  • fifty-nine (59).

If you land on one of these squares, you again move the number of spaces on your die roll, in the direction you are currently moving.

On an initial roll of six and three, the player advances to square twenty-six (26).

On an initial roll of four and five, the player advances to square fifty-three (53). The squares have no special significance at any other time. A roll of nine at any other time in the game is played normally.

There are several other squares with additional features.

  • Square six (6) is The Bridge and the player immediately advances to square twelve (12).
  • Square forty-two (42) is The Maze and the player is sent back to square thirty (30).
  • Square nineteen (19) is the The Tavern and the player loses two turns.
  • Square thirty-one (31) is The Well. A player landing there must remain until another player lands on that square. The second player then remains there while the first player returns to the square the second player started that turn from.
  • Square fifty-two (52) is The Prison which is played exactly the same as The Well.
  • Square fifty-eight (58) is Death and the player starts over

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

3. What may be the goal of the team?

Answered: 1 week ago

Question

2. What type of team would you recommend?

Answered: 1 week ago