Skip to content

Commit

Permalink
- init
Browse files Browse the repository at this point in the history
  • Loading branch information
teceP committed Feb 15, 2020
0 parents commit 86f77c8
Show file tree
Hide file tree
Showing 13 changed files with 680 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions TicTacToe - Human Enemy.iml
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>
32 changes: 32 additions & 0 deletions src/main/Main.java
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();

}
}
62 changes: 62 additions & 0 deletions src/spielbrett/MyRectangle.java
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;
}
}
64 changes: 64 additions & 0 deletions src/spielbrett/Spielbrett.java
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;
}

}
Loading

0 comments on commit 86f77c8

Please sign in to comment.