diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..ac4a647 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/DESIGN.md b/DESIGN.md index b581809..08821d8 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -7,29 +7,50 @@ CompSci 308 : RPS Design Initial Design ======= -###Class 1 - -* Bullets are made with asterisks - -1. You can also order things with numbers - - -###Class 2 - +###GameWorld +'''java + private void loadUI() + private void startGame() + private Map> loadWeaponsData(File weaponData) + private void printAndUpdateResults(Player player1, Player player2) + private void newRound() + private void endGame() + private void reset() + private Weapon chooseWeapon() + private void showWinner(Player player1, Player player2); +''' +* loadUI() is responsible for generating the user interface for the game. +* loadWeaponsData(File weaponData) is responsible for reading a file of weapons and creating a map with relationships between weapons in the form of a Map. +* startGame() is responsible for instantiating Players (setting their scores and other stats to zero). +* printAndUpdateResults(Player player1, Player player2) is responsible for displaying the results between two players and updating their scores. +* newRound() clears the weapon choices of players. +* endGame() stops the UI running. +* reset() reinitializes scores and weapon choices for players (restarts the game without closing the UI). + + +###Weapon +'''java + public Weapon(String name, Collection listOfCanBeat) + public int compareTo(Weapon other) +''' +* Weapon(String name, Collection listOfCanBeat) is a constructor that initializes a weapon with a name and the list of other weapons it can beat. +* compareTo(String other) determines whether two weapons are the same or who beats who. + +###Player +'''java + public Player(int score) + public Weapon getWeapon(); + public void addScore(int score); +''' +* Player(int score) is a constructor initializes with a score CRC Design ======= -###Class 1 - - -###Class 2 - -You can add images as well: - -![This is cool, too bad you can't see it](crc-example.png "Our CRC cards") - +![This is cool, too bad you can't see it](IMG_9844.JPG "Our CRC cards") +![This is cool, too bad you can't see it](IMG_9845.JPG "Our CRC cards") +![This is cool, too bad you can't see it](IMG_9846.JPG "Our CRC cards") Use Cases ======= @@ -37,11 +58,18 @@ Use Cases You can put blocks of code in here like this: ```java public int getTotal (Collection data) { - int total = 0; - for (int d : data) { - total += d; - } - return total; + Player p1 = new Player(0); + Player p2 = new Player(0); + startRound(); + int win = p1.getWeapon().compareTo(p2.getWeapon()); + if (win == 1) { + p1.addScore(1); + } else if (win == -1){ + p2.addScore(1); + } + showWinner(p1, p2); } ``` +'' + diff --git a/IMG_9844.JPG b/IMG_9844.JPG new file mode 100644 index 0000000..f42c773 Binary files /dev/null and b/IMG_9844.JPG differ diff --git a/IMG_9845.JPG b/IMG_9845.JPG new file mode 100644 index 0000000..85db574 Binary files /dev/null and b/IMG_9845.JPG differ diff --git a/IMG_9846.JPG b/IMG_9846.JPG new file mode 100644 index 0000000..e5653e2 Binary files /dev/null and b/IMG_9846.JPG differ diff --git a/build.fxbuild b/build.fxbuild new file mode 100644 index 0000000..97f9d7b --- /dev/null +++ b/build.fxbuild @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/application/Main.java b/src/application/Main.java new file mode 100644 index 0000000..c0cfc7d --- /dev/null +++ b/src/application/Main.java @@ -0,0 +1,26 @@ +package application; + +import javafx.application.Application; +import javafx.stage.Stage; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; + + +public class Main extends Application { + @Override + public void start(Stage primaryStage) { + try { + BorderPane root = new BorderPane(); + Scene scene = new Scene(root,400,400); + scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); + primaryStage.setScene(scene); + primaryStage.show(); + } catch(Exception e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) { + launch(args); + } +} diff --git a/src/application/application.css b/src/application/application.css new file mode 100644 index 0000000..83d6f33 --- /dev/null +++ b/src/application/application.css @@ -0,0 +1 @@ +/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */ \ No newline at end of file