Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA game design The game is a puzzle; the objective is to place all eight color

ID: 2246329 • Letter: J

Question

JAVA game design

The game is a puzzle; the objective is to place all eight colored playing pieces
onto a board comprising 25 pegs which are arranged in a grid. The placement must
ensure that all of the pieces fit together correctly.

The game is played on a board comprised of 50 locations arranged
in a 5x10 grid. 25 of the locations have pegs which are the same
height as a single layer of the pieces (each of which are two layers
high, described below, and seen in the photo above). The locations are encoded with letters A-Y
and a-y, according to the picture below and encoding scheme which is described below. When
pieces are played, each ring in their lower layer must be on a peg and
as a consequence, each ring on their upper layer will be at a location
that is not a peg.

The game comprises 8 playing shapes, each of which is made of
plastic and consists of five or six flat rings arranged in two
layers (see the photo above). Each layer has an arrangement of two
or three rings. The thickness of the rings is the same as the height
of the board pegs, so once a piece is played, the upper layer of rings
always sits neatly above the top of the pegs. The two layers of rings
are fused together. The two layers are offset from each other by half
a peg space (rings are never directly on top another). See the
illustration of all pieces and their possible orientatons below. The
center-most ring is defined to be the home of the piece (the
placement of the piece is defined in terms of the placement of the
center ring). Shapes may be flipped and rotated, so the home ring may
be on the top or bottom layer at the time it is played. For
orientations A-D, the home ring is on the bottom layer. For
orientations E-H, the home ring is on the top layer (see the illustration of all shapes and their eight orientations, below).

Question

Just write a sketch/skeleton version, including all important classes, with the most important fields and methods. The methods may have empty bodies.

What we expect:

You to demonstrate a design that clearly shows how your group thinks it will solve the problem.

Your design must be committed and pushed to your group repo.

We expect that your design will change as your understanding of the problem grows deeper. What we want in this deliverable is just your initial thoughts.

Explanation / Answer

Solution======================================

import java.util.ArrayList;

class RingSet{
  
   //Separate top and bottom layers for easier tranformations
   char topLayer[][];
   char bottomLayer[][];
  
   //Helpful in Describing required orientation
   public static enum Orientation{
       FLIP_HORIZONTAL,
       FLIP_VERTICAL,
       ROTATE_CW,
       ROTATE_CCW,
       RESET
   }
  
  
   public RingSet(char[][] topLayer,char [][]bottomLayer){
       //If its not following the rules,e.g if its overlapping, return an error  
       if(!isFusable(topLayer,bottomLayer)){
               System.out.println("ERROR!!Layers can't be fused");
           }
   }

   private boolean isFusable(char[][] topLayer2, char[][] bottomLayer2) {

       return false;
   }
  
   public void transformRingSet(Orientation orientation){
       //transform the array, based on the orientation
       //separate methods should be created to handle each kind
       //of transformation, e.g. void rotateCW();
   }
  
   //Display, how it looks
   public void display(){
      
   }
  
  
}


class GameBoard{
  
   //The char array which emulates the grid
   private char grid[][];
  
   //It will hold all the rings, that are being used in this game board
   //Can be used, when we need to remove a Ringset from board
   //Or to check if the same RingSet is being added twice
   private ArrayList<RingSet> ringSets;
  
   //How many total pegs have been covered by Rings
   private int totalPegsCovered;
  
   private int totalPegs;
  
   //Game board size can be changes, by putting more rows and cols
   public GameBoard(int rows,int cols){
       grid=new char[rows][cols];
       totalPegsCovered=0;
       totalPegs=(rows*cols)/2;
       ringSets=new ArrayList<>();
      
       encodeGrid();
   }

   private void encodeGrid() {
       //Grid must be encoded with chars A-Y
       //and a-y, for better identification
       //purposes
      
   }
  
   public boolean isPlaceable(RingSet ringset, int row, int column){
       //One can check if the ringset is placeable on the
       //Desired row,col(top corner)
       //i.e if its within the bounds of grid
       //and its not overlapping any other RingSet
       //and its not a RingSet, that is already being used in this board
       return false;
   }
  
   public boolean placeRingSet(RingSet ringset, int row, int column){
       if(isPlaceable(ringset,row,column)){
           //Place rings and update grid
           return true;
       }
       return false;
   }
  
   public boolean removeRingSet(RingSet ringset){
       //Just like in real world, we can remove
       //The ringSet, by searching in the arraylist
       //And updating grid for the same
       //Return false, if its not in the arraylist
       return false;
   }
  
   //One can always check is the puzzle is now complete
   public boolean isPuzzleComplete(){
      
       if(totalPegsCovered==totalPegs){
           return true;
       }
      
       return false;
   }
  
  
   //Display the game board
   public void displayBoard(){
      
   }
  
}

Feel free to ask, if any doubts..