public class PlayingField
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
Disc[][] |
discs |
int[] |
discsincol |
Constructor and Description |
---|
PlayingField(int w,
int h,
Player p1,
Player p2,
Player t)
Create a new playing field.
|
Modifier and Type | Method and Description |
---|---|
Player |
checkWin()
Function to check if the previous move was a winning move.
|
PlayingField |
clone()
Make a clone of the current playing field.
|
int |
countDiscs()
Function to get the amount of discs in the playing field.
|
int |
getColumnHeight(int col)
Get the height of the specified column.
|
Disc |
getDiscAt(int col,
int row)
Get the disc at the specified colum and row.
|
int |
getheight()
Get the height of the playing field.
|
Disc |
getLastMove()
Get the disc of the previous move.
|
Player |
getTurn()
Get the player who's turn it is.
|
int |
getWidth()
Get the width of the playing field.
|
Disc[] |
getWinningSequence()
Function to return an array of discs that are part of the winning sequence.
|
boolean |
isColumnFull(int col)
Function to check if the specified column is completely filled with discs.
|
boolean |
isFull()
Function to check if the complete playing field is filled with discs.
|
void |
printField()
Print the current field in the standard output.
|
boolean |
putDisc(int c,
Player player)
Function to place a new disc in the playing field.
|
public Disc[][] discs
public int[] discsincol
public PlayingField(int w, int h, Player p1, Player p2, Player t)
w
- Width of the field.h
- Height of the field.p1
- Player 1.p2
- player 2.t
- Initial turn.public int getWidth()
public int getheight()
public Player getTurn()
public int getColumnHeight(int col)
col
- The column.public Disc getDiscAt(int col, int row)
col
- The column.row
- The row.public boolean isColumnFull(int col)
col
- The column.public boolean isFull()
public Player checkWin()
public Disc[] getWinningSequence()
public int countDiscs()
public boolean putDisc(int c, Player player)
c
- The column.player
- The owner of the player.public Disc getLastMove()
public PlayingField clone()
clone
in class java.lang.Object
public void printField()