Question: package controllers; import models.Square; import models.StraightLine; import models.Tetronimo; import models.Z; import views.TetrisBoard; import models.L; import java.util.Random; public class TetrisController { private final TetrisBoard TETRIS _
package controllers;
import models.Square;
import models.StraightLine;
import models.Tetronimo;
import models.Z;
import views.TetrisBoard;
import models.L;
import java.util.Random;
public class TetrisController
private final TetrisBoard TETRISBOARD;
public TetrisController TetrisBoard tetrisBoard
this.TETRISBOARD tetrisBoard;
Randomly chooses the next tetronimo and returns it INCOMPLETE
@return The next tetronimo to be played
public Tetronimo getNextTetromino
Tetronimo tetronimo;
Create a Random instance
Random random new Random;
Randomly select a Tetronimo type
int randomType random.nextInt; Generates a number between and
switch randomType
case :
tetronimo new Square;
break;
case :
tetronimo new StraightLine;
break;
case :
tetronimo new Z;
break;
case :
tetronimo new L;
break;
default:
throw new IllegalStateExceptionUnexpected value: randomType;
Set the location of the Tetronimo
tetronimo.setLocation Tetronimo.SIZE;
return tetronimo;
Method to determine if the tetronimo has landed INCOMPLETE
@param tetronimo The tetronimo to evaluate
@return True if the tetronimo has landed on the bottom of the board or another tetronimo false if it has not
public boolean tetronimoLanded Tetronimo tetronimo
int nextY tetronimo.getYLocation tetronimo.getHeight Tetronimo.SIZE;
return nextY ;
package models;
import wheelsunh.users.Animator;
import wheelsunh.users.Rectangle;
import wheelsunh.users.ShapeGroup;
import java.awt.;
public abstract class Tetronimo extends ShapeGroup
Constant to represent the size of the tetronimo
public static final int SIZE;
protected Rectangle r;
protected Rectangle r;
protected Rectangle r;
protected Rectangle r;
protected Rectangle r;
protected int curRotation ;
Generates the four rectangles for the tetronino and puts them on the screen, they are at the default coordinates
to start
public Tetronimo
super;
this.r new Rectangle;
this.rsetSize Tetronimo.SIZE, Tetronimo.SIZE ;
this.rsetFrameColor Color.BLACK ;
this.r new Rectangle;
this.rsetSize Tetronimo.SIZE, Tetronimo.SIZE ;
this.rsetFrameColor Color.BLACK ;
this.r new Rectangle;
this.rsetSize Tetronimo.SIZE, Tetronimo.SIZE ;
this.rsetFrameColor Color.BLACK ;
this.r new Rectangle;
this.rsetSize Tetronimo.SIZE, Tetronimo.SIZE ;
this.rsetFrameColor Color.BLACK ;
Increments the rotation of the tetronimo, other classes need to override this to provide the full functionality
public void rotate
this.curRotation;
Shifts the tetronimo left one row
public void shiftLeft
super.setLocation super.getXLocation Tetronimo.SIZE, super.getYLocation;
Shifts the tetronimo right one row
public void shiftRight
super.setLocation super.getXLocation Tetronimo.SIZE, super.getYLocation;
I already have all of my shapes and am able to randomize them. But I am having a lot of trouble with Instructions Views
This package is simply going to contain the GUI for the game. You are going to need to add to my GUI a place for the score and also a preview of the next block to be dropped.The controllers package is where you need to implement the logic for the game. You can break up the logic into as many or as few classes as you see fit, but your package must handle the following:
Detecting when a row or rows have been filled and shifting down the blocks from the rows above
Scoring the game
Detecting when the game is over
Randomly choosing the next piece to drop
Detecting when a piece has fallen as far as it possibly can I have started this for you, you will need to finish it Thank you
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
