Merge branch 'master' of https://gitlab.cecs.anu.edu.au/u7156831/comp1110-ass2
This commit is contained in:
commit
0402735e96
16
.idea/artifacts/game.xml
Normal file
16
.idea/artifacts/game.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" build-on-make="true" name="game">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/game</output-path>
|
||||
<root id="archive" name="game.jar">
|
||||
<element id="module-output" name="comp1110-ass2" />
|
||||
<element id="extracted-dir" path="$PATH_TO_FX$/javafx-swt.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PATH_TO_FX$/javafx.web.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PATH_TO_FX$/javafx.base.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PATH_TO_FX$/javafx.fxml.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PATH_TO_FX$/javafx.media.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PATH_TO_FX$/javafx.swing.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PATH_TO_FX$/javafx.controls.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PATH_TO_FX$/javafx.graphics.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
52
admin/D-originality-u7156831.yml
Normal file
52
admin/D-originality-u7156831.yml
Normal file
@ -0,0 +1,52 @@
|
||||
# IMPORTANT: It is very important that you correctly complete this originality
|
||||
# statement.
|
||||
#
|
||||
# This is your statement of your submitted work being your own.
|
||||
# Incorrectly filling out this statement could lead to charges
|
||||
# of academic misconduct.
|
||||
#
|
||||
# For information on how to fill this out correctly, see
|
||||
# https://cs.anu.edu.au/courses/comp1110/help/faq/09-originality/
|
||||
#
|
||||
|
||||
declaration: >-
|
||||
I declare that everything I have submitted for stage D of this assignment
|
||||
and all stages before it is entirely my own work, with the following
|
||||
exceptions:
|
||||
|
||||
# Use this to list names of people who you collaborated with, and a
|
||||
# comment about what you collaborated on.
|
||||
#
|
||||
# Add as many "name+comment" entries as necessary
|
||||
# (or remove it altogether if you haven't collaborated with anyone)
|
||||
# collaboration:
|
||||
# - name:
|
||||
# comment: >-
|
||||
|
||||
# Use this to list any code that you used that you did not write,
|
||||
# aside from code provided by the lecturer. Provide a comment
|
||||
# explaining your use and the URL to that code and the licence for
|
||||
# that code
|
||||
#
|
||||
# Add as many "url+licence+comment" entries as necessary
|
||||
# (or remove it altogether if you haven't used any external code)
|
||||
# code:
|
||||
# - comment:
|
||||
# url:
|
||||
# licence:
|
||||
|
||||
# Use this to list any assets (artwork, sound, etc) that you used.
|
||||
# Provide a comment explaining your use of that asset and the URL
|
||||
# and license for the asset
|
||||
#
|
||||
# Add as many "url+licence+comment" entries as necessary
|
||||
# (or remove it altogether if you haven't used any external assets)
|
||||
# assets:
|
||||
# - comment:
|
||||
# url:
|
||||
# licence:
|
||||
|
||||
|
||||
# sign *your* name and uid here
|
||||
name: Nathan Woodburn
|
||||
uid: u7156831
|
3
src/META-INF/MANIFEST.MF
Normal file
3
src/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: comp1110.ass2.gui.Game
|
||||
|
@ -1,13 +1,6 @@
|
||||
package comp1110.ass2;
|
||||
|
||||
import gittest.A;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.lang.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class BlueLagoon {
|
||||
// The Game Strings for five maps have been created for you.
|
||||
@ -57,7 +50,16 @@ public class BlueLagoon {
|
||||
}
|
||||
|
||||
// Check if the state string matches the regex string
|
||||
return stateString.matches(matchString);
|
||||
if (!stateString.matches(matchString)) return false;
|
||||
|
||||
// Check that there is one and only one of each player id
|
||||
// This fixed test 2-3 of D2DTests.testIsStateStringWellFormed
|
||||
int numPlayers = Integer.parseInt(stateString.substring(stateString.indexOf(";") - 1, stateString.indexOf(";")));
|
||||
for (int i = 0; i < numPlayers; i++) {
|
||||
if (stateString.length() - stateString.replaceAll("p "+i,"").length() != 3) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,8 +201,8 @@ public class BlueLagoon {
|
||||
* Importantly, players can now only play on the sea if it is
|
||||
* adjacent to a piece they already own.
|
||||
*
|
||||
// * @param stateString a string representing a game state
|
||||
// * @param moveString a string representing the current player's move
|
||||
* @param stateString a string representing a game state
|
||||
* @param moveString a string representing the current player's move
|
||||
* @return true if the current player can make the move and false otherwise
|
||||
*/
|
||||
public static boolean isMoveValid(String stateString, String moveString) {
|
||||
@ -524,7 +526,7 @@ public class BlueLagoon {
|
||||
ArrayList<String> coordsContainer = new ArrayList<>();
|
||||
|
||||
for (String island : islands) {
|
||||
if (!island.substring(0, 2).equals("i ")) continue;
|
||||
if (!island.startsWith("i ")) continue;
|
||||
coordsContainer.addAll(Arrays.asList(island.substring(4).split(" ")));
|
||||
}
|
||||
|
||||
|
72
tests/comp1110/ass2/D2DTests.java
Normal file
72
tests/comp1110/ass2/D2DTests.java
Normal file
@ -0,0 +1,72 @@
|
||||
package comp1110.ass2;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* This class is used to test BlueLagoon methods/functions.
|
||||
* This was completed for Task D2D.
|
||||
*
|
||||
*/
|
||||
public class D2DTests {
|
||||
|
||||
/**
|
||||
* This method is to show how to write a test.
|
||||
* It is not a real test as it does not test anything.
|
||||
*/
|
||||
@Test
|
||||
public void exampleTest() {
|
||||
// Here are variables used in this example test.
|
||||
// Change them to see how the test behaves.
|
||||
boolean alwaysTrue = true;
|
||||
boolean alwaysFalse = false;
|
||||
int alwaysOne = 1;
|
||||
int alwaysTwo = 2;
|
||||
String alwaysHello = "Hello";
|
||||
String alwaysWorld = "World";
|
||||
int[] alwaysOneTwoThree = {1,2,3};
|
||||
|
||||
|
||||
|
||||
// To run a test to see if two values are equal, use the following:
|
||||
|
||||
Assertions.assertTrue(alwaysTrue,"The test failed because alwaysTrue was not true");
|
||||
Assertions.assertFalse(alwaysFalse,"The test failed because alwaysFalse was not false");
|
||||
Assertions.assertEquals(alwaysOne*2, alwaysTwo, "The test failed because alwaysOne*2 was not equal to alwaysTwo");
|
||||
Assertions.assertEquals(alwaysHello + " " + alwaysWorld, "Hello World", "The test failed because alwaysHello + \" \" + alwaysWorld was not equal to \"Hello World\"");
|
||||
Assertions.assertArrayEquals(new int[]{1,2,3}, alwaysOneTwoThree, "The test failed because new int[]{1,2,3} was not equal to alwaysOneTwoThree");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to test the isStateStringWellFormed method.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testIsStateStringWellFormed() {
|
||||
|
||||
String DEFAULT_GAME = "a 13 2; c 0 E; i 6 0,0 0,1 0,2 0,3 1,0 1,1 1,2 1,3 1,4 2,0 2,1; i 6 0,5 0,6 0,7 1,6 1,7 1,8 2,6 2,7 2,8 3,7 3,8; i 6 7,12 8,11 9,11 9,12 10,10 10,11 11,10 11,11 11,12 12,10 12,11; i 8 0,9 0,10 0,11 1,10 1,11 1,12 2,10 2,11 3,10 3,11 3,12 4,10 4,11 5,11 5,12; i 8 4,0 5,0 5,1 6,0 6,1 7,0 7,1 7,2 8,0 8,1 8,2 9,0 9,1 9,2; i 8 10,3 10,4 11,0 11,1 11,2 11,3 11,4 11,5 12,0 12,1 12,2 12,3 12,4 12,5; i 10 3,3 3,4 3,5 4,2 4,3 4,4 4,5 5,3 5,4 5,5 5,6 6,3 6,4 6,5 6,6 7,4 7,5 7,6 8,4 8,5; i 10 5,8 5,9 6,8 6,9 7,8 7,9 7,10 8,7 8,8 8,9 9,7 9,8 9,9 10,6 10,7 10,8 11,7 11,8 12,7 12,8; s 0,0 0,5 0,9 1,4 1,8 1,12 2,1 3,5 3,7 3,10 3,12 4,0 4,2 5,9 5,11 6,3 6,6 7,0 7,8 7,12 8,2 8,5 9,0 9,9 10,3 10,6 10,10 11,0 11,5 12,2 12,8 12,11; r C B W P S; p 0 0 0 0 0 0 0 S T; p 1 0 0 0 0 0 0 S T;";
|
||||
Assertions.assertTrue(BlueLagoon.isStateStringWellFormed(DEFAULT_GAME), "The test failed because DEFAULT_GAME was marked as an invalid state string");
|
||||
System.out.println("Test 1 passed");
|
||||
// Test adding multiple player with the same id (Caused Error 1)
|
||||
String DEFAULT_WITH_ADDED = DEFAULT_GAME + " p 1 0 0 0 0 0 0 S T;";
|
||||
Assertions.assertFalse(BlueLagoon.isStateStringWellFormed(DEFAULT_WITH_ADDED), "The test failed because DEFAULT with double Player 1 was marked as a valid state string");
|
||||
System.out.println("Test 2 passed");
|
||||
DEFAULT_WITH_ADDED = DEFAULT_GAME + " p 0 0 0 0 0 0 0 S T;";
|
||||
Assertions.assertFalse(BlueLagoon.isStateStringWellFormed(DEFAULT_WITH_ADDED), "The test failed because DEFAULT with double Player 0 was marked as a valid state string");
|
||||
System.out.println("Test 3 passed");
|
||||
|
||||
// Test adding `a 13 2; `
|
||||
DEFAULT_WITH_ADDED = "a 13 2; "+ DEFAULT_GAME;
|
||||
Assertions.assertFalse(BlueLagoon.isStateStringWellFormed(DEFAULT_WITH_ADDED), "The test failed because DEFAULT with double init was marked as a valid state string");
|
||||
System.out.println("Test 4 passed");
|
||||
|
||||
|
||||
|
||||
/* This test found Errors as below
|
||||
Errors found by this test are:
|
||||
1. The method did not check if the player was included twice.
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user