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
e60d8e20
Commit
e60d8e20
authored
Nov 14, 2014
by
Stefano Cobelli
Browse files
Merge branch 'MattsBranch' of git@gitlab.bucknell.edu:sjc032/205_hw02.git into MattsBranch
parents
4df4606e
48fb94c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/model/player/BlockerPlayerTest.java
0 → 100644
View file @
e60d8e20
/**
* CSCI 205 - Software Design and Engineering
* Name(s): Matt Tower
*
* Work: hw02
* Created: Nov 14, 2014, 4:27:48 PM
*/
package
model.player
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
model.Game
;
import
model.Mark
;
import
org.junit.Test
;
/**
* @author mjt023
*
* This is the BlockerPlayerTest class that tests the BlockerPlayer
* class.
*/
public
class
BlockerPlayerTest
{
/** a game instance */
private
Game
theGame
;
/** a blocker player instance */
private
BlockerPlayer
blockerPlayer
;
/**
* tests the decideMove() method
*/
@Test
public
void
decideMoveTest
()
{
theGame
=
new
Game
(
3
);
blockerPlayer
=
new
BlockerPlayer
(
theGame
.
getBoard
(),
Mark
.
O
);
// test for horizontal win
theGame
.
getBoard
().
setMark
(
0
,
0
,
Mark
.
X
);
theGame
.
getBoard
().
setMark
(
0
,
1
,
Mark
.
X
);
blockerPlayer
.
decideMove
();
assertTrue
(
theGame
.
getBoard
().
getMark
(
0
,
2
)
==
Mark
.
O
);
theGame
.
getBoard
().
clear
();
// test for diagonal win
theGame
.
getBoard
().
setMark
(
0
,
0
,
Mark
.
X
);
theGame
.
getBoard
().
setMark
(
2
,
2
,
Mark
.
X
);
blockerPlayer
.
decideMove
();
assertTrue
(
theGame
.
getBoard
().
getMark
(
1
,
1
)
==
Mark
.
O
);
theGame
.
getBoard
().
clear
();
// test for vertical win
theGame
.
getBoard
().
setMark
(
0
,
0
,
Mark
.
X
);
theGame
.
getBoard
().
setMark
(
2
,
0
,
Mark
.
X
);
blockerPlayer
.
decideMove
();
assertTrue
(
theGame
.
getBoard
().
getMark
(
1
,
0
)
==
Mark
.
O
);
}
}
src/model/player/RandomPlayerTest.java
deleted
100644 → 0
View file @
4df4606e
/**
* CSCI 205 - Software Design and Engineering
* Name(s): Matt Tower
*
* Work: hw02
* Created: Nov 11, 2014, 8:18:37 PM
*/
package
model.player
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
model.Board
;
import
model.Mark
;
import
org.junit.Before
;
import
org.junit.Test
;
/**
* @author mjt023
*
*/
public
class
RandomPlayerTest
{
/** a board instance */
private
Board
theBoard
;
/** a RandomPlayer instance */
private
RandomPlayer
randPlayer
;
/** size of the board */
private
int
size
;
@Before
public
void
before
()
{
theBoard
=
new
Board
(
size
);
randPlayer
=
new
RandomPlayer
(
theBoard
,
Mark
.
X
);
size
=
3
;
theBoard
.
setMark
(
0
,
0
,
Mark
.
O
);
theBoard
.
setMark
(
0
,
1
,
Mark
.
X
);
theBoard
.
setMark
(
0
,
2
,
Mark
.
O
);
theBoard
.
setMark
(
1
,
0
,
Mark
.
X
);
theBoard
.
setMark
(
1
,
1
,
Mark
.
O
);
}
/**
* tests the decideMove() method
*/
@Test
public
void
decideMoveTest
()
{
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
randPlayer
.
decideMove
();
}
assertTrue
(
randPlayer
.
decideMove
());
assertTrue
(
randPlayer
.
decideMove
());
assertTrue
(
randPlayer
.
decideMove
());
assertTrue
(
randPlayer
.
decideMove
());
assertFalse
(
randPlayer
.
decideMove
());
}
}
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