Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stefano Cobelli
205_hw02
Commits
2f9e6c00
Commit
2f9e6c00
authored
Nov 11, 2014
by
Stefano Cobelli
Browse files
Blocker Player update. Mark now includes getOppositeMark()
parent
797aa64c
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/model/Mark.java
View file @
2f9e6c00
...
...
@@ -34,4 +34,19 @@ public enum Mark {
public
String
getSign
()
{
return
this
.
sign
;
}
/**
* gets the opposite mark of the current one. None's opposite is none
*
* @return Mark
*/
public
Mark
getOppositeMark
()
{
if
(
this
.
sign
.
equals
(
"X"
))
return
O
;
else
if
(
this
.
sign
.
equals
(
"O"
))
return
X
;
else
return
NONE
;
}
}
src/model/player/AutoPlayable.java
View file @
2f9e6c00
...
...
@@ -18,5 +18,4 @@ public interface AutoPlayable {
public
int
getDecidedRow
();
public
int
getDecidedCol
();
}
src/model/player/BlockerPlayer.java
View file @
2f9e6c00
...
...
@@ -7,10 +7,107 @@
*/
package
model.player
;
import
model.Board
;
import
model.Mark
;
/**
* @author mjt023
*
*/
public
class
BlockerPlayer
{
public
class
BlockerPlayer
extends
Player
implements
AutoPlayable
{
/**
* @param theBoard
* @param myMark
*/
public
BlockerPlayer
(
Board
theBoard
,
Mark
myMark
)
{
super
(
theBoard
,
myMark
);
}
/*
* (non-Javadoc)
*
* @see model.player.AutoPlayable#decideMove()
*/
@Override
public
boolean
decideMove
()
{
return
false
;
}
/*
* (non-Javadoc)
*
* @see model.player.AutoPlayable#getDecidedRow()
*/
@Override
public
int
getDecidedRow
()
{
// TODO Auto-generated method stub
return
0
;
}
/*
* (non-Javadoc)
*
* @see model.player.AutoPlayable#getDecidedCol()
*/
@Override
public
int
getDecidedCol
()
{
// TODO Auto-generated method stub
return
0
;
}
/**
* Looks to see if two of the other players marks are in a specified row and
* the spot to block is not taken
*
* @param row
* @return col in spot to block. -1 if can't block
*/
public
int
findTwoInRow
(
int
row
)
{
if
}
/**
* Looks to see if two of the other players marks are in a specified col and
* the spot to block is not taken
*
* @param col
* @return row in spot to block. -1 if can't block
*/
public
int
findTwoInCol
(
int
col
)
{
}
/**
* Looks to see if two of the other players marks are in the NorthEast
* diagnal. returns the row if there's a spot to block
*
* @return row in spot to block. -1 if can't block
*/
public
int
findTwoInDiagNE
()
{
}
/**
* Looks to see if two of the other players marks are in the NorthWest
* diagnal. returns the row if there's a spot to block
*
* @return row in spot to block. -1 if can't block
*/
public
int
findTwoInDiagNW
()
{
}
/**
* Checks three marks to see if there's a blocking opertunity
*
* @param mark0
* @param mark1
* @param mark2
* @return the index of the spot to block
*/
public
int
checkThreeSpots
(
Mark
mark0
,
Mark
mark1
,
Mark
mark2
)
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment