Marble Solitaire

A strategy game that involves moving marbles around to create empty spaces until there is only one
marble left.

Running the program
There are 2 ways to run the Marble Solitaire program:

1. Using command-line arguments
2. Using a JAR file

Code Structure

1. Model
The model controls the logic of the game. The model has two interfaces:

MarbleSolitaireModel
  • Represents the various models that the game can be played with.
  • AbstractSolitaireModel implements MarbleSolitaireModel and represents an abstract version of a standard model. It allows a customizable arm size and position of the first blank spot. It includes various methods to play the game, like building the board, moving a piece, and checking when the game is over.
  • EnglishSolitaireModel extends AbstractSolitaireModel and represents a normal English game which is in a plus shape.
  • EuropeanSolitaireModel extends AbstractSolitaireModel and represents a normal English game which is in a hexagon shape.
  • TriangleSolitaireModel extends AbstractSolitaireModel and represents a normal English game which is in a triangle shape. Has a few override methods because of the unique challenges that a triangle shape creates.
MarbleSolitaireModelState
  • Allows access to information about the model without changing the current model. Relays this information to the View so it can accurately portray the model.
  • MarbleSolitaireModel extends MarbleSolitaireModelState so that it can have access to the current model.

2. Controller
Represents operations that should be offered by a controller to run the game. The Controller has one interface:

MarbleSolitaireController
  • Represents a controller that parses user commands for the game.
  • MarbleSolitaireControllerImpl implements MarbleSolitaireController and contains a method that parses any user inputs and relays them to model and view. It catches exceptions if a user makes a wrong move and has a private method to make sure that the user only inputs numbers for the move command.
3. View
The view relays information to the user through a text view or GUI. It contains two interfaces:

MarbleSolitaireView
  • Represents the text view for the game
  • AbstractSolitaireView implements MarbleSolitaireView and has various methods to render the view to the user. The text view renders both the board and any messages from the controller like a new move or a user error.
  • TriangleSolitaireTextView extends MarbleSolitaireView and renders a triangle model to the user. The unique nature of a triangle requires a separate view unlike the other models.
  • ModelSolitaireTextView extends AbstractSolitaireView and takes in a standard model like English or European.
MarbleSolitaireGUIView
  • Represents a GUI view for the game
  • SwingGUIView implements MarbleSolitaireGUIView and uses various JavaSwing methods to render a GUI to the user.

marblediagram 1
Screen Shot 2023-02-07 at 8.20 1 Screen Shot 2023-02-07 at 8.22 1 Screen Shot 2023-02-07 at 8.26 1
Back