From 4240ac37cde8db57446815a660a7baff7cb0fe9a Mon Sep 17 00:00:00 2001 From: Malte Tammena Date: Fri, 13 Oct 2017 11:04:14 +0200 Subject: [PATCH] Worked on Game --- Makefile | 38 ++++++++++++++++++++++++++++++++++++++ src/game/Game.java | 21 +++++++++++++++++++-- src/player/Player.java | 2 -- 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7037d36 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +JAVA=java +JAVAC=javac +JAVADOC=javadoc +JAR=jar + +JAVAC_OPTIONS=-Xlint:all +JAVADOC_OPTIONS=-Xdoclint:all -private -encoding UTF-8 -charset UTF-8 -docencoding UTF-8 + +BUILDS=builds +DOC=doc +CLASSPATH=src +LIBARIES= +CLASSES=\ +src/game/Main.java \ +src/game/Game.java \ +src/player/Player.java + +OBJECTS=$($(subst $(CLASSPATH),$(BUILDS),$(CLASSES)):.java=.class) + +BUILDFILES=$(OBJECTS) $(FXMLS_BUILD) + +MAIN=game.Main + + +all: $(CLASSES) $(FXMLS_BUILD) + $(JAVAC) $(JAVAC_OPTIONS) -cp $(CLASSPATH):$(LIBARIES) $(CLASSES) -d $(BUILDS) + +run: $(CLASSES) + $(JAVA) -cp $(BUILDS):$(LIBARIES) $(MAIN) + +doc: $(CLASSES) + $(JAVADOC) $(JAVADOC_OPTIONS) -cp $(CLASSPATH):$(LIBARIES) $(CLASSES) -d $(DOC) + +jar: all + $(JAR) -cfe VierGewinnt.jar $(MAIN) -C $(BUILDS) . + +clean: + rm -rf $(BUILDS)/* $(DOC)/* VierGewinnt.jar diff --git a/src/game/Game.java b/src/game/Game.java index 00020a6..bd116fd 100644 --- a/src/game/Game.java +++ b/src/game/Game.java @@ -1,6 +1,6 @@ package game; -import math.Random; +import java.util.Random; import player.Player; // import player.Player1; @@ -10,20 +10,37 @@ public class Game { private final Player p1; private final Player p2; + private int[][] board; + private boolean gameOn; public Game(Player p1, Player p2) { this.p1 = p1; this.p2 = p2; + this.board = new int [7][6]; } public void start() { Random ran = new Random(); + Player first; + Player second; + if (ran.nextBoolean()) { + first = this.p1; + second = this.p2; + } else { + first = this.p2; + second = this.p1; + } + while(gameOn) { - + makeMove(first); } } + private void makeMove(Player p) { + + } + private void log(String s) { } diff --git a/src/player/Player.java b/src/player/Player.java index 4f6685a..f7d6016 100644 --- a/src/player/Player.java +++ b/src/player/Player.java @@ -2,8 +2,6 @@ package player; public interface Player { - private String name; - public int move(int[][] game); public String getName(); }