computer science
SnakeEyeGame/.DS_Store
__MACOSX/SnakeEyeGame/._.DS_Store
SnakeEyeGame/build/classes/.netbeans_automatic_build
__MACOSX/SnakeEyeGame/build/classes/._.netbeans_automatic_build
SnakeEyeGame/build/classes/.netbeans_update_resources
__MACOSX/SnakeEyeGame/build/classes/._.netbeans_update_resources
SnakeEyeGame/build/classes/Dice.class
public synchronized class Dice { private Die die1; private Die die2; void Dice(); public int roll(); public int getFaceValueDie1(); public int getFaceValueDie2(); }
__MACOSX/SnakeEyeGame/build/classes/._Dice.class
SnakeEyeGame/build/classes/DiceTester.class
public synchronized class DiceTester { public void DiceTester(); public static void main(String[]); }
__MACOSX/SnakeEyeGame/build/classes/._DiceTester.class
SnakeEyeGame/build/classes/Die.class
public synchronized class Die { private int face; private java.util.Random rnd; void Die(); public void roll(); public int getFaceValue(); }
__MACOSX/SnakeEyeGame/build/classes/._Die.class
SnakeEyeGame/build/classes/DieTester.class
public synchronized class DieTester { public void DieTester(); public static void main(String[]); }
__MACOSX/SnakeEyeGame/build/classes/._DieTester.class
SnakeEyeGame/build/classes/GameController.class
public synchronized class GameController { public static final int NOT_STARTED = 0; public static final int PLAYING = 1; public static final int WIN = 2; private Dice dice; private Player player1; private Player player2; private ScoreBoard scoreBoard; private int gameState; public void GameController(Dice, Player, Player); private void updateGameState(Player); public void startGame(); public void init(); public int getCurrentGameState(); }
__MACOSX/SnakeEyeGame/build/classes/._GameController.class
SnakeEyeGame/build/classes/Player.class
public synchronized class Player { private String name; private int score; private java.util.Scanner kb; void Player(String); public String getName(); public int getScore(); public void updateScore(int); public void takeTurn(Dice); public boolean playAgain(); }
__MACOSX/SnakeEyeGame/build/classes/._Player.class
SnakeEyeGame/build/classes/ScoreBoard.class
public synchronized class ScoreBoard { public void ScoreBoard(); public void showScore(String); }
__MACOSX/SnakeEyeGame/build/classes/._ScoreBoard.class
SnakeEyeGame/build/classes/SnakeEyeGame.class
public synchronized class SnakeEyeGame { public void SnakeEyeGame(); public static void main(String[]); }
__MACOSX/SnakeEyeGame/build/classes/._SnakeEyeGame.class
__MACOSX/SnakeEyeGame/build/._classes
__MACOSX/SnakeEyeGame/._build
SnakeEyeGame/build.xml
Builds, tests, and runs the project SnakeEyeGame.
__MACOSX/SnakeEyeGame/._build.xml
SnakeEyeGame/manifest.mf
Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build
__MACOSX/SnakeEyeGame/._manifest.mf
SnakeEyeGame/nbproject/.DS_Store
__MACOSX/SnakeEyeGame/nbproject/._.DS_Store
SnakeEyeGame/nbproject/build-impl.xml
Must set src.dir Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir Must set build.test.classes.dir Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar Must set javac.includes No tests executed. Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agent Must select some files in the IDE or set javac.includes To run this application from the command line without Ant, try: java -jar "${dist.jar.resolved}" Must select one file in the IDE or set run.class Must select one file in the IDE or set run.class Must select one file in the IDE or set debug.class Must select one file in the IDE or set debug.class Must set fix.includes This target only works when run from inside the NetBeans IDE. Must select one file in the IDE or set profile.class This target only works when run from inside the NetBeans IDE. This target only works when run from inside the NetBeans IDE. This target only works when run from inside the NetBeans IDE. Must select one file in the IDE or set run.class Must select some files in the IDE or set test.includes Must select one file in the IDE or set run.class Must select one file in the IDE or set applet.url Must select some files in the IDE or set javac.includes Some tests failed; see details above. Must select some files in the IDE or set test.includes Some tests failed; see details above. Must select some files in the IDE or set test.class Must select some method in the IDE or set test.method Some tests failed; see details above. Must select one file in the IDE or set test.class Must select one file in the IDE or set test.class Must select some method in the IDE or set test.method Must select one file in the IDE or set applet.url Must select one file in the IDE or set applet.url
__MACOSX/SnakeEyeGame/nbproject/._build-impl.xml
SnakeEyeGame/nbproject/genfiles.properties
build.xml.data.CRC32=53b9b878 build.xml.script.CRC32=274b3c2e [email protected] # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=53b9b878 nbproject/build-impl.xml.script.CRC32=1cc1a632 nbproject/[email protected]
__MACOSX/SnakeEyeGame/nbproject/._genfiles.properties
SnakeEyeGame/nbproject/private/.DS_Store
__MACOSX/SnakeEyeGame/nbproject/private/._.DS_Store
SnakeEyeGame/nbproject/private/private.properties
compile.on.save=true user.properties.file=C:\\Users\\mrahman\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
__MACOSX/SnakeEyeGame/nbproject/private/._private.properties
SnakeEyeGame/nbproject/private/private.xml
file:/H:/COMP1230_Summer_2018/SnakeEyeGame/src/DieTester.java file:/H:/COMP1230_Summer_2018/SnakeEyeGame/src/Die.java file:/H:/COMP1230_Summer_2018/SnakeEyeGame/src/Dice.java file:/H:/COMP1230_Summer_2018/SnakeEyeGame/src/Player.java file:/H:/COMP1230_Summer_2018/SnakeEyeGame/src/SnakeEyeGame.java file:/H:/COMP1230_Summer_2018/SnakeEyeGame/src/DiceTester.java file:/H:/COMP1230_Summer_2018/SnakeEyeGame/src/ScoreBoard.java file:/H:/COMP1230_Summer_2018/SnakeEyeGame/src/GameController.java
__MACOSX/SnakeEyeGame/nbproject/private/._private.xml
__MACOSX/SnakeEyeGame/nbproject/._private
SnakeEyeGame/nbproject/project.properties
annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated build.generated.sources.dir=${build.dir}/generated-sources # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results # Uncomment to specify the preferred debugger connection transport: #debug.transport=dt_socket debug.classpath=\ ${run.classpath} debug.test.classpath=\ ${run.test.classpath} # Files in build.classes.dir which should be excluded from distribution jar dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/SnakeEyeGame.jar dist.javadoc.dir=${dist.dir}/javadoc excludes= includes=** jar.compress=false javac.classpath= # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.external.vm=true javac.processorpath=\ ${javac.classpath} javac.source=1.8 javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= main.class= manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} # Space-separated list of JVM arguments used when running the project. # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. # To set system properties for unit tests define test-sys-prop.name=value: run.jvmargs= run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} source.encoding=UTF-8 src.dir=src test.src.dir=test
__MACOSX/SnakeEyeGame/nbproject/._project.properties
SnakeEyeGame/nbproject/project.xml
org.netbeans.modules.java.j2seproject SnakeEyeGame
__MACOSX/SnakeEyeGame/nbproject/._project.xml
__MACOSX/SnakeEyeGame/._nbproject
SnakeEyeGame/src/Dice.java
SnakeEyeGame/src/Dice.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* It encapsulates the Dice (two-Die) for the SnakeEye game.
*
@author
mrahman
*/
public
class
Dice
{
// ivars for two Die
private
Die
die1
,
die2
;
/**
* initialize both Dies
*/
Dice
(){
die1
=
new
Die
();
die2
=
new
Die
();
}
/**
* Simulates rolling to two-die at the same time.
*
@return
the sum of faceValues of both Dies
*/
public
int
roll
(){
die1
.
roll
();
die2
.
roll
();
return
die1
.
getFaceValue
()
+
die2
.
getFaceValue
();
}
/**
* Getter method for the faceValue of Die1.
*
@return
face value of Die1.
*/
public
int
getFaceValueDie1
(){
return
die1
.
getFaceValue
();
}
/**
* Getter method for the faceValue of Die2.
*
@return
face value of Die2.
*/
public
int
getFaceValueDie2
(){
return
die2
.
getFaceValue
();
}
}
__MACOSX/SnakeEyeGame/src/._Dice.java
SnakeEyeGame/src/DiceTester.java
SnakeEyeGame/src/DiceTester.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
*
@author
mrahman
*/
public
class
DiceTester
{
public
static
void
main
(
String
[]
args
)
{
Dice
d
=
new
Dice
();
System
.
out
.
println
(
d
.
roll
());
System
.
out
.
println
(
"Face value of Die 1 is "
+
d
.
getFaceValueDie1
());
System
.
out
.
println
(
"Face value of Die 2 is "
+
d
.
getFaceValueDie2
());
}
}
__MACOSX/SnakeEyeGame/src/._DiceTester.java
SnakeEyeGame/src/Die.java
SnakeEyeGame/src/Die.java
import
java
.
util
.
Random
;
/**
* This class models a real-world six-sided die.
*
@author
mrahman
*/
public
class
Die
{
// ivar to maintain current faceValue of the Die object
private
int
face
;
private
Random
rnd
;
/**
* The default faceValue for the die is 0 (invalid);
*/
Die
(){
face
=
0
;
rnd
=
new
Random
();
}
/**
* rolls the dice and randomly selects a face value between 1 and 6.
*/
public
void
roll
(){
face
=
rnd
.
nextInt
(
6
)
+
1
;
}
/**
* Getter method for the face value of the die.
*
@return
the current face value
*/
public
int
getFaceValue
(){
return
face
;
}
}
__MACOSX/SnakeEyeGame/src/._Die.java
SnakeEyeGame/src/DieTester.java
SnakeEyeGame/src/DieTester.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
*
@author
mrahman
*/
public
class
DieTester
{
public
static
void
main
(
String
[]
args
)
{
Die
d
=
new
Die
();
d
.
roll
();
System
.
out
.
println
(
"the face value "
+
d
.
getFaceValue
());
}
}
__MACOSX/SnakeEyeGame/src/._DieTester.java
SnakeEyeGame/src/GameController.java
SnakeEyeGame/src/GameController.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
*
@author
mrahman
*/
public
class
GameController
{
public
static
final
int
NOT_STARTED
=
0
;
public
static
final
int
PLAYING
=
1
;
public
static
final
int
WIN
=
2
;
// public static final int PLAYER2_WIN = 3;
private
Dice
dice
;
private
Player
player1
,
player2
;
private
ScoreBoard
scoreBoard
;
private
int
gameState
;
/**
*
*
@param
d
*
@param
p1
*
@param
p2
*/
public
GameController
(
Dice
d
,
Player
p1
,
Player
p2
)
{
dice
=
d
;
player1
=
p1
;
player2
=
p2
;
scoreBoard
=
new
ScoreBoard
();
gameState
=
NOT_STARTED
;
}
private
void
updateGameState
(
Player
p
){
if
(
p
.
getScore
()
>=
100
){
gameState
=
WIN
;
scoreBoard
.
showScore
(
"Winner! "
+
p
.
getName
());
}
}
/**
* Call this method to start the Snake Eye Game.
*/
public
void
startGame
(){
gameState
=
PLAYING
;
while
(
gameState
==
PLAYING
){
do
{
player1
.
takeTurn
(
dice
);
updateGameState
(
player1
);
}
while
(
player1
.
playAgain
()
&&
gameState
==
PLAYING
);
while
(
gameState
==
PLAYING
){
player2
.
takeTurn
(
dice
);
updateGameState
(
player2
);
if
(
player2
.
playAgain
()
==
false
)
break
;
}
}
}
/**
* Re-sets the game state to NOT_STARTED.
*/
public
void
init
(){
gameState
=
NOT_STARTED
;
}
public
int
getCurrentGameState
(){
return
gameState
;
}
}
__MACOSX/SnakeEyeGame/src/._GameController.java
SnakeEyeGame/src/Player.java
SnakeEyeGame/src/Player.java
import
java
.
util
.
Scanner
;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
*
@author
mrahman
*/
public
class
Player
{
private
String
name
;
private
int
score
;
private
Scanner
kb
;
/**
* Inits the score to zero.
*
@param
name name of the player.
*/
Player
(
String
name
){
this
.
name
=
name
;
score
=
0
;
kb
=
new
Scanner
(
System
.
in
);
}
public
String
getName
(){
return
name
;
}
/**
*
*
@return
*/
public
int
getScore
(){
return
score
;
}
/**
*
*
@param
score
*/
public
void
updateScore
(
int
score
){
this
.
score
=
score
;
}
/**
* Player takes turn;
* - first, he rolls the dice and updates its score
*
*
*
@param
d the Dice passed to the player.
*/
public
void
takeTurn
(
Dice
d
){
System
.
out
.
println
(
name
+
" is rolling...."
);
int
cs
=
d
.
roll
();
System
.
out
.
println
(
"Current score of "
+
name
+
" is "
+
score
);
System
.
out
.
println
(
name
+
" rolled "
+
cs
);
if
(
cs
==
2
){
updateScore
(
0
);
}
else
if
(
d
.
getFaceValueDie1
()
!=
1
&&
d
.
getFaceValueDie2
()
!=
1
){
updateScore
(
score
+
cs
);
}
else
{
System
.
out
.
println
(
name
+
" rolled a 1, hence no score update at this round."
);
}
}
/**
* Asks the user if he/she wants to play again or not?
*
@return
true if the player wants to play again; false otherwise
*/
public
boolean
playAgain
(){
System
.
out
.
println
(
name
+
" : Do you want to try again? (y/n)"
);
String
choice
=
kb
.
nextLine
();
if
(
choice
.
equalsIgnoreCase
(
"y"
))
return
true
;
return
false
;
}
}
__MACOSX/SnakeEyeGame/src/._Player.java
SnakeEyeGame/src/ScoreBoard.java
SnakeEyeGame/src/ScoreBoard.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
*
@author
mrahman
*/
public
class
ScoreBoard
{
public
void
showScore
(
String
message
){
System
.
out
.
println
(
message
);
}
}
__MACOSX/SnakeEyeGame/src/._ScoreBoard.java
SnakeEyeGame/src/SnakeEyeGame.java
SnakeEyeGame/src/SnakeEyeGame.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
*
@author
mrahman
*/
public
class
SnakeEyeGame
{
public
static
void
main
(
String
[]
args
)
{
Player
p1
=
new
Player
(
"ABC"
);
Player
p2
=
new
Player
(
"XYZ"
);
Dice
d
=
new
Dice
();
GameController
gc
=
new
GameController
(
d
,
p1
,
p2
);
gc
.
init
();
gc
.
startGame
();
}
}