Skip to content

Commit 133f99a

Browse files
JoeJoe
Joe
authored and
Joe
committedMay 2, 2017
Added Game logic
1 parent 7128694 commit 133f99a

10 files changed

+1793
-0
lines changed
 

‎build.xml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- You may freely edit this file. See commented blocks below for -->
3+
<!-- some examples of how to customize the build. -->
4+
<!-- (If you delete it and reopen the project it will be recreated.) -->
5+
<!-- By default, only the Clean and Build commands use this build script. -->
6+
<!-- Commands such as Run, Debug, and Test only use this build script if -->
7+
<!-- the Compile on Save feature is turned off for the project. -->
8+
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
9+
<!-- in the project's Project Properties dialog box.-->
10+
<project name="CSE310_Project" default="default" basedir=".">
11+
<description>Builds, tests, and runs the project CSE310 Project.</description>
12+
<import file="nbproject/build-impl.xml"/>
13+
<!--
14+
15+
There exist several targets which are by default empty and which can be
16+
used for execution of your tasks. These targets are usually executed
17+
before and after some main targets. They are:
18+
19+
-pre-init: called before initialization of project properties
20+
-post-init: called after initialization of project properties
21+
-pre-compile: called before javac compilation
22+
-post-compile: called after javac compilation
23+
-pre-compile-single: called before javac compilation of single file
24+
-post-compile-single: called after javac compilation of single file
25+
-pre-compile-test: called before javac compilation of JUnit tests
26+
-post-compile-test: called after javac compilation of JUnit tests
27+
-pre-compile-test-single: called before javac compilation of single JUnit test
28+
-post-compile-test-single: called after javac compilation of single JUunit test
29+
-pre-jar: called before JAR building
30+
-post-jar: called after JAR building
31+
-post-clean: called after cleaning build products
32+
33+
(Targets beginning with '-' are not intended to be called on their own.)
34+
35+
Example of inserting an obfuscator after compilation could look like this:
36+
37+
<target name="-post-compile">
38+
<obfuscate>
39+
<fileset dir="${build.classes.dir}"/>
40+
</obfuscate>
41+
</target>
42+
43+
For list of available properties check the imported
44+
nbproject/build-impl.xml file.
45+
46+
47+
Another way to customize the build is by overriding existing main targets.
48+
The targets of interest are:
49+
50+
-init-macrodef-javac: defines macro for javac compilation
51+
-init-macrodef-junit: defines macro for junit execution
52+
-init-macrodef-debug: defines macro for class debugging
53+
-init-macrodef-java: defines macro for class execution
54+
-do-jar: JAR building
55+
run: execution of project
56+
-javadoc-build: Javadoc generation
57+
test-report: JUnit report generation
58+
59+
An example of overriding the target for project execution could look like this:
60+
61+
<target name="run" depends="CSE310_Project-impl.jar">
62+
<exec dir="bin" executable="launcher.exe">
63+
<arg file="${dist.jar}"/>
64+
</exec>
65+
</target>
66+
67+
Notice that the overridden target depends on the jar target and not only on
68+
the compile target as the regular run target does. Again, for a list of available
69+
properties which you can use, check the target you are overriding in the
70+
nbproject/build-impl.xml file.
71+
72+
-->
73+
</project>

‎manifest.mf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
X-COMMENT: Main-Class will be added automatically by build
3+

‎nbproject/build-impl.xml

+1,419
Large diffs are not rendered by default.

‎nbproject/genfiles.properties

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build.xml.data.CRC32=4f8b0d0f
2+
build.xml.script.CRC32=d8e04253
3+
build.xml.stylesheet.CRC32=8064a381@1.79.1.48
4+
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5+
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6+
nbproject/build-impl.xml.data.CRC32=4f8b0d0f
7+
nbproject/build-impl.xml.script.CRC32=aece8a60
8+
nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48

‎nbproject/project.properties

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
annotation.processing.enabled=true
2+
annotation.processing.enabled.in.editor=false
3+
annotation.processing.processor.options=
4+
annotation.processing.processors.list=
5+
annotation.processing.run.all.processors=true
6+
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7+
build.classes.dir=${build.dir}/classes
8+
build.classes.excludes=**/*.java,**/*.form
9+
# This directory is removed when the project is cleaned:
10+
build.dir=build
11+
build.generated.dir=${build.dir}/generated
12+
build.generated.sources.dir=${build.dir}/generated-sources
13+
# Only compile against the classpath explicitly listed here:
14+
build.sysclasspath=ignore
15+
build.test.classes.dir=${build.dir}/test/classes
16+
build.test.results.dir=${build.dir}/test/results
17+
# Uncomment to specify the preferred debugger connection transport:
18+
#debug.transport=dt_socket
19+
debug.classpath=\
20+
${run.classpath}
21+
debug.test.classpath=\
22+
${run.test.classpath}
23+
# Files in build.classes.dir which should be excluded from distribution jar
24+
dist.archive.excludes=
25+
# This directory is removed when the project is cleaned:
26+
dist.dir=dist
27+
dist.jar=${dist.dir}/CSE310_Project.jar
28+
dist.javadoc.dir=${dist.dir}/javadoc
29+
excludes=
30+
includes=**
31+
jar.compress=false
32+
javac.classpath=
33+
# Space-separated list of extra javac options
34+
javac.compilerargs=
35+
javac.deprecation=false
36+
javac.external.vm=true
37+
javac.processorpath=\
38+
${javac.classpath}
39+
javac.source=1.8
40+
javac.target=1.8
41+
javac.test.classpath=\
42+
${javac.classpath}:\
43+
${build.classes.dir}
44+
javac.test.processorpath=\
45+
${javac.test.classpath}
46+
javadoc.additionalparam=
47+
javadoc.author=false
48+
javadoc.encoding=${source.encoding}
49+
javadoc.noindex=false
50+
javadoc.nonavbar=false
51+
javadoc.notree=false
52+
javadoc.private=false
53+
javadoc.splitindex=true
54+
javadoc.use=true
55+
javadoc.version=false
56+
javadoc.windowtitle=
57+
main.class=cse310.project.CSE310Project
58+
manifest.file=manifest.mf
59+
meta.inf.dir=${src.dir}/META-INF
60+
mkdist.disabled=false
61+
platform.active=default_platform
62+
run.classpath=\
63+
${javac.classpath}:\
64+
${build.classes.dir}
65+
# Space-separated list of JVM arguments used when running the project.
66+
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67+
# To set system properties for unit tests define test-sys-prop.name=value:
68+
run.jvmargs=
69+
run.test.classpath=\
70+
${javac.test.classpath}:\
71+
${build.test.classes.dir}
72+
source.encoding=UTF-8
73+
src.dir=src
74+
test.src.dir=test

‎nbproject/project.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://www.netbeans.org/ns/project/1">
3+
<type>org.netbeans.modules.java.j2seproject</type>
4+
<configuration>
5+
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
6+
<name>CSE310 Project</name>
7+
<source-roots>
8+
<root id="src.dir"/>
9+
</source-roots>
10+
<test-roots>
11+
<root id="test.src.dir"/>
12+
</test-roots>
13+
</data>
14+
</configuration>
15+
</project>

‎src/Game.java

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
2+
import java.util.Vector;
3+
4+
/*
5+
* To change this license header, choose License Headers in Project Properties.
6+
* To change this template file, choose Tools | Templates
7+
* and open the template in the editor.
8+
*/
9+
10+
/**
11+
*
12+
* @author Joe
13+
*/
14+
public class Game {
15+
Player playerX, playerO;
16+
17+
//
18+
char[] board;
19+
20+
public Game() {
21+
22+
}
23+
public boolean start(){
24+
if(playerX == null || playerO == null){
25+
return false;
26+
}
27+
else{
28+
board = new char[9];
29+
for(int i =0; i< board.length; i++){
30+
board[i] = ' ';
31+
}
32+
return true;
33+
}
34+
}
35+
36+
public int placeO(int place){
37+
if(board[place-1] == ' '){
38+
board[place-1] = 'O';
39+
return place;
40+
}
41+
else return -1;
42+
43+
}
44+
45+
46+
public int placex(int place){
47+
if(board[place-1] == ' '){
48+
board[place-1] = 'X';
49+
return place;
50+
}
51+
else return -1;
52+
53+
}
54+
55+
public boolean evaluateX(){
56+
//rows
57+
if(board[0] == 'X' && board[1]== 'X' && board[2] == 'X' ){
58+
return true;
59+
}
60+
if(board[3] == 'X' && board[4] == 'X' && board[5] == 'X' ){
61+
return true;
62+
}
63+
if(board[6] == 'X' && board[7]== 'X' && board[8] == 'X' ){
64+
return true;
65+
}
66+
//columns
67+
if(board[0] == 'X' && board[3]== 'X' && board[6] == 'X' ){
68+
return true;
69+
}
70+
if(board[1] == 'X' && board[4]== 'X' && board[7] == 'X' ){
71+
return true;
72+
}
73+
if(board[2] == 'X' && board[5]== 'X' && board[8] == 'X' ){
74+
return true;
75+
}
76+
//diagonals
77+
if(board[0] == 'X' && board[4]== 'X' && board[8] == 'X' ){
78+
return true;
79+
}
80+
if(board[2] == 'X' && board[4]== 'X' && board[6] == 'X' ){
81+
return true;
82+
}
83+
return false;
84+
}
85+
86+
87+
public boolean evaluateO(){
88+
//rows
89+
if(board[0] == 'O' && board[1]== 'O' && board[2] == 'O' ){
90+
return true;
91+
}
92+
if(board[3] == 'O' && board[4] == 'O' && board[5] == 'O' ){
93+
return true;
94+
}
95+
if(board[6] == 'O' && board[7]== 'O' && board[8] == 'O' ){
96+
return true;
97+
}
98+
//columns
99+
if(board[0] == 'O' && board[3]== 'O' && board[6] == 'O' ){
100+
return true;
101+
}
102+
if(board[1] == 'O' && board[4]== 'O' && board[7] == 'O' ){
103+
return true;
104+
}
105+
if(board[2] == 'O' && board[5]== 'O' && board[8] == 'O' ){
106+
return true;
107+
}
108+
//diagonals
109+
if(board[0] == 'O' && board[4]== 'O' && board[8] == 'O' ){
110+
return true;
111+
}
112+
if(board[2] == 'O' && board[4]== 'O' && board[6] == 'O' ){
113+
return true;
114+
}
115+
return false;
116+
}
117+
118+
public Game(Player playerX, Player PlayerO) {
119+
this.playerX = playerX;
120+
this.playerO = PlayerO;
121+
}
122+
123+
public Player getPlayerX() {
124+
return playerX;
125+
}
126+
127+
public void setPlayerX(Player playerX) {
128+
this.playerX = playerX;
129+
}
130+
131+
public Player getPlayerO() {
132+
return playerO;
133+
}
134+
135+
public void setPlayerO(Player PlayerO) {
136+
this.playerO = PlayerO;
137+
}
138+
139+
140+
141+
}

‎src/Player.java

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
7+
/**
8+
*
9+
* @author Joe
10+
*/
11+
public class Player {
12+
String id;
13+
String address;
14+
15+
public Player(String id, String address) {
16+
this.id = id;
17+
this.address = address;
18+
}
19+
20+
public Player() {
21+
}
22+
23+
public String getId() {
24+
return id;
25+
}
26+
27+
public void setId(String id) {
28+
this.id = id;
29+
}
30+
31+
public String getAddress() {
32+
return address;
33+
}
34+
35+
public void setAddress(String address) {
36+
this.address = address;
37+
}
38+
39+
}

‎README.md ‎src/README.md

File renamed without changes.

‎src/cse310/project/CSE310Project.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package cse310.project;
7+
8+
/**
9+
*
10+
* @author Joe
11+
*/
12+
public class CSE310Project {
13+
14+
/**
15+
* @param args the command line arguments
16+
*/
17+
public static void main(String[] args) {
18+
// TODO code application logic here
19+
}
20+
21+
}

0 commit comments

Comments
 (0)
Please sign in to comment.