-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 86f77c8
Showing
13 changed files
with
680 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
import spielbrett.SpielbrettController; | ||
|
||
import java.io.File; | ||
|
||
public class Main extends Application { | ||
|
||
public static void main(String[] args){ | ||
launch(args); | ||
} | ||
|
||
@Override | ||
public void start(Stage primaryStage) throws Exception { | ||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("view/spielbrett_view.fxml")); | ||
fxmlLoader.setController(new SpielbrettController()); | ||
Parent root = fxmlLoader.load(); | ||
|
||
Scene scene = new Scene(root, 600, 400); | ||
primaryStage.setScene(scene); | ||
primaryStage.setTitle("TicTacToe - Mario Teklic - Programmfabrik"); | ||
primaryStage.setResizable(false); | ||
|
||
primaryStage.show(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package spielbrett; | ||
|
||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
import spieler.SpielerEnum; | ||
import java.awt.*; | ||
|
||
public class MyRectangle extends Rectangle { | ||
|
||
private StringProperty zeileUndSpalte = new SimpleStringProperty(""); | ||
private SpielerEnum spieler; | ||
private int zeile; | ||
private int spalte; | ||
|
||
public void setZeile(){ | ||
this.zeile = this.wandleCharZuInt(this.getZeileUndSpalte().charAt(0)); | ||
} | ||
|
||
public void setSpalte(){ | ||
this.spalte = this.wandleCharZuInt(this.getZeileUndSpalte().charAt(1)); | ||
} | ||
|
||
/** | ||
* Wandelt einen Character in den entspechenden Int-Wert um | ||
* @param character | ||
* @return -1, falls Character keinem der vorgesehenen entspricht | ||
*/ | ||
public static int wandleCharZuInt(char character){ | ||
switch(character){ | ||
case('A'): | ||
return 0; | ||
case('B'): | ||
return 1; | ||
case('C'): | ||
return 2; | ||
default: | ||
return -1; | ||
} | ||
} | ||
|
||
|
||
|
||
public final String getZeileUndSpalte(){ | ||
return this.zeileUndSpalte.get(); | ||
} | ||
|
||
public final void setZeileUndSpalte(String zeileUndSpalte){ | ||
this.zeileUndSpalte.set(zeileUndSpalte); | ||
} | ||
|
||
public StringProperty getZeileUndSpalteProperty(){ | ||
return this.zeileUndSpalte; | ||
} | ||
|
||
public SpielerEnum getSpieler() { | ||
return spieler; | ||
} | ||
|
||
public void setSpieler(SpielerEnum spieler) { | ||
this.spieler = spieler; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package spielbrett; | ||
|
||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
import spieler.SpielerEnum; | ||
|
||
public class Spielbrett { | ||
|
||
private MyRectangle[][] felder; | ||
private SpielerEnum amZug; | ||
private StringProperty aktuelleNachricht; | ||
|
||
public Spielbrett() { | ||
this.aktuelleNachricht = new SimpleStringProperty("Willkommen zu TicTacToe! Starte das Spiel unten rechts."); | ||
this.felder = new MyRectangle[3][3]; | ||
|
||
for(int c = 0; c < felder.length; c++){ | ||
for(int r = 0; r < felder.length; r++){ | ||
felder[c][r] = new MyRectangle(); | ||
} | ||
} | ||
} | ||
|
||
public void reset(){ | ||
for(int c = 0; c < felder.length; c++){ | ||
for(int r = 0; r < felder.length; r++){ | ||
felder[c][r].setSpieler(null); | ||
} | ||
} | ||
} | ||
|
||
public MyRectangle getFeld(int zeile, int spalte){ | ||
return this.felder[zeile][spalte]; | ||
} | ||
|
||
public MyRectangle[][] getFelder() { | ||
return felder; | ||
} | ||
|
||
public void setFelder(MyRectangle[][] felder) { | ||
this.felder = felder; | ||
} | ||
|
||
public final String getAktuelleNachricht() { | ||
return this.aktuelleNachricht.toString(); | ||
} | ||
|
||
public final void setAktuelleNachricht(String neueNachricht) { | ||
this.aktuelleNachricht.set(neueNachricht); | ||
} | ||
|
||
public final StringProperty aktuelleNachrichtProperty() { | ||
return this.aktuelleNachricht; | ||
} | ||
|
||
public SpielerEnum getAmZug() { | ||
return amZug; | ||
} | ||
|
||
public void setAmZug(SpielerEnum spielerEnum) { | ||
this.amZug = spielerEnum; | ||
} | ||
|
||
} |
Oops, something went wrong.