Practical Assessment 2 | My Assignment Tutor

Te Hoe Hōkai PakihiDepartment of Enterprise and Digital InnovationBachelor of Information and Communication TechnologiesGraduate Diploma in Information and Communication TechnologiesBest Programming Practices(Java)BCDE223Assessment TwoPractical Assessment 2Semester One, 2021Due date: Friday, 28 May 2021Time: 5pmTOTAL MARKS: 100Student Name/ID ……………………………………………………………………………………Ara Institute of Canterbury and its division members reserve the right to use electronicmeans to detect and help prevent plagiarism. Students agree that when submittingthis assignment, it may be subject to submission for textual similarity review toTurnitin.com.Submissions received late will be subject to a penalty of 10% of the student’smark per working day.This assessment is worth 25% of the total marks for this course.To pass this course, students must gain an average of at least 50% across allassessments, and gain at least 50% in Assessment 3.This paper has twenty-four (24) pages including the cover sheet.Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 2© AraThis assessment relates to the following Learning Outcome(s):• Demonstrate ability to implement a prototype systemOverviewYou are to create the first part of a program that will enable a user to play an Eyeball Mazegame. This will be written in Java. Naturally, you will be expected to use good design,programming, and testing practices.For an overview of Eyeball Maze game, try it at https://www.logicmazes.com/eyeball.html.Outside the Scope• Creating Eyeball mazes programmatically• Solving an Eyeball maze programmatically• Checking if a given state of an Eyeball maze can be solved• Creating a • Creating a • No Level Editor• No Filing SystemProvided FilesYou will be provided with a set of interfaces, enums and unit tests for the major componentsof Eyeball Maze game. You MUST use them.Required Structures• The row and the column numbering are 0-based. The coordinate of the most top-leftposition is (0, 0).TaskYou need to design, write, and test a that will be able to be used later inassociation with a in Assessment 3.This means you need to:1. Design your using a class diagram, which should include the interfacesand enums provided2. Code your 3. Make your code pass the unit tests provided belowYou may work in groups for creating your code, but must make individual presentations.Clearly comment the source of all code that is not your own. You may use code provided byothers in the class but will only be marked on code you have written.Students should show the progress of their assessment work to the course tutor every weekand get formative feedback.Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 3© AraNot Deliverable• and , although you may wish to create them to assist withyour debugging / testing• Load from or write to diskSubmissionStudents must zip and submit their work including the items listed below into the correspondingdrop box on the course Moodle site by the deadline indicated.1. A 10-minute MAXIMUM (optionally narrated) PowerPoint slide presentationexplaining how much of the you have implemented.2. A digital copy of the project code including unit testing code3. A digital copy of the class diagram createdThe presentation should cover the following issues.1. Design of the structure you have implemented. This includes at least aUML Class diagram.2. How many of the unit tests which prove the correctness of the your codepass?3. The expected (i.e., self-marking) marks for each task you expect to get marks forMarking RubricThe maximum marks for class diagram are 5 as indicated below. 012345ClassDiagramNotattemptedAnalysisleveldiagramDesignleveldiagram ofdatastructuresDesignleveldiagram ofstructuresandattributesDesignleveldiagram ofstructures,attributes,andmethodsDesignleveldiagram ofstructures,attributes,methods,andinterfaces The code implementing the class diagram correctly gets 1 mark if it can pass 1unit test provided. 95 unit tests have been provided in total. Therefore, the maximum marksfor the code are 95.Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 4© AraInterfaces and Enumspublic enum Shape {DIAMOND, CROSS, STAR, FLOWER, BLANK, LIGHTNING}public enum Color {BLUE, RED, YELLOW, GREEN, BLANK, PURPLE}public enum Direction {UP, DOWN, LEFT, RIGHT}public enum Message {OK,DIFFERENT_SHAPE_OR_COLOR,BACKWARDS_MOVE,MOVING_OVER_BLANK,MOVING_DIAGONALLY}public interface ILevelHolder {public void addLevel(int height, int width);public int getLevelWidth();public int getLevelHeight();public void setLevel(int levelNumber);public int getLevelCount();}public interface IGoalHolder {public void addGoal(int row, int column);public int getGoalCount();public boolean hasGoalAt(int targetRow, int targetColumn);public int getCompletedGoalCount();}public interface ISquareHolder {public void addSquare(Square square, int row, int column);public Color getColorAt(int row, int column);public Shape getShapeAt(int row, int column);}public interface IEyeballHolder {public void addEyeball(int row, int column, Direction direction);public int getEyeballRow();public int getEyeballColumn();public Direction getEyeballDirection();}public interface IMoving {public boolean canMoveTo( int destinationRow, int destinationColumn);public Message MessageIfMovingTo(int destinationRow, intdestinationColumn);public boolean isDirectionOK(int destinationRow, int destinationColumn);public Message checkDirectionMessage(int destinationRow, intdestinationColumn);public boolean hasBlankFreePathTo(int destinationRow, intdestinationColumn);public Message checkMessageForBlankOnPathTo(int destinationRow, intdestinationColumn);public void moveTo(int destinationRow, int destinationColumn);}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 5© AraUnit Testsimport static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.Test;class TestGameHoldsLevels {Game game = new Game();void addTestLevel1() {game.addLevel(1, 5);}void addTestLevel2() {game.addLevel(7, 3);}@Testvoid testGetLevelWidth() {this.addTestLevel1();int expectedWidth = 5;int actualWidth = game.getLevelWidth();assertEquals(expectedWidth, actualWidth);}@Testvoid testGetLevelHeight() {this.addTestLevel1();int expectedHeight = 1;int actualHeight = game.getLevelHeight();assertEquals(expectedHeight, actualHeight);}@Testvoid testGetLevelCountWithOneLevel() {this.addTestLevel1();int expectedLevelCount = 1;int actuallevelCount = game.getLevelCount();assertEquals(expectedLevelCount, actuallevelCount);}@Testvoid testGetLevelCountWithTwoLevels() {this.addTestLevel1();this.addTestLevel2();int expectedLevelCount = 2;int actuallevelCount = game.getLevelCount();assertEquals(expectedLevelCount, actuallevelCount);}@Testvoid testMostRecentlyAddedLevelIsCurrentLevelbyCheckingSize() {this.addTestLevel1();this.addTestLevel2();int[] expectedLevelSize = { 7, 3 };int[] actualLevelSize = { game.getLevelHeight(), game.getLevelWidth()};assertArrayEquals(expectedLevelSize, actualLevelSize);}@Testvoid testSettingLevelChangesCurrentLevelbyCheckingSize() {this.addTestLevel1();this.addTestLevel2();int[] expectedLevelSize = { 1, 5 };game.setLevel(0);Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 6© Araint[] actualLevelSize = { game.getLevelHeight(), game.getLevelWidth()};assertArrayEquals(expectedLevelSize, actualLevelSize);}@Testvoid testSettingLeveltoToolargeNumberThrowsException() {this.addTestLevel1();this.addTestLevel2();assertThrows(IllegalArgumentException.class, () -> {game.setLevel(42);});}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 7© Araimport static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.BeforeEach;import org.junit.jupiter.api.Test;class TestLevelHoldsGoals {Game game;@BeforeEachvoid add7High3WideLevel() throws Exception {game = new Game();game.addLevel(7, 3);}@Testvoid testAddingOneGoalIncreasesGoalCountTo1() {// this.add7High3WideLevel();game.addGoal(4, 2);int expectedGoalCount = 1;int actualGoalCount = game.getGoalCount();assertEquals(expectedGoalCount, actualGoalCount);}@Testvoid testAddingOneGoalputsGoalAtExpectedPosition() {// this.add7High3WideLevel();game.addGoal(4, 2);boolean hasGoal = game.hasGoalAt(4, 2);assertTrue(hasGoal);}@Testvoid testAddingTwoGoalIncreasesGoalCountto2() {// this.add7High3WideLevel();game.addGoal(4, 2);game.addGoal(6, 1);int expectedGoalCount = 2;int actualGoalCount = game.getGoalCount();assertEquals(expectedGoalCount, actualGoalCount);}@Testvoid testAddingTwoGoalsPutsGoalsAtExpectedPositions() {// this.add7High3WideLevel();game.addGoal(4, 2);game.addGoal(6, 1);boolean[] expectedHasGoals = { true, true };boolean[] actualHasGoals = { game.hasGoalAt(4, 2), game.hasGoalAt(6,1) };assertArrayEquals(expectedHasGoals, actualHasGoals);}@Testvoid testNewGamehas0CompletedGoals() {// this.add7High3WideLevel();game.addGoal(4, 2);game.addGoal(6, 1);int expectedGoalCount = 0;int actualGoalCount = game.getCompletedGoalCount();assertEquals(expectedGoalCount, actualGoalCount);}@Testvoid testAddingGoalsOutsideLevelHeightThrowsRangeException() {// this.add7High3WideLevel();assertThrows(IllegalArgumentException.class, () -> {Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 8© Aragame.addGoal(8, 2);});}@Testvoid testAddingGoalsOutsideLevelWidthThrowsRangeException() {// this.add7High3WideLevel();assertThrows(IllegalArgumentException.class, () -> {game.addGoal(2, 9);});}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 9© Araimport static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.Test;class TestGameHoldsSquares {Game game = new Game();private void setup() {game = new Game();game.addLevel(9, 1);game.addSquare(new BlankSquare(), 0, 0);game.addSquare(new BlankSquare(), 1, 0);game.addSquare(new PlayableSquare(Color.BLUE, Shape.DIAMOND), 2, 0);game.addSquare(new PlayableSquare(Color.RED, Shape.CROSS), 3, 0);game.addSquare(new PlayableSquare(Color.YELLOW, Shape.STAR), 4, 0);game.addSquare(new PlayableSquare(Color.GREEN, Shape.FLOWER), 5, 0);game.addSquare(new PlayableSquare(Color.PURPLE, Shape.LIGHTNING), 6,0);game.addSquare(new BlankSquare(), 7, 0);game.addSquare(new BlankSquare(), 8, 0);}@Testvoid testAddingSquareOutsideLevelWidthThrowsException() {game = new Game();game.addLevel(9, 1);assertThrows(IllegalArgumentException.class, () -> {game.addSquare(new BlankSquare(), 0, 4);});}@Testvoid testAddingSquareOutsideLevelHeightThrowsException() {game = new Game();game.addLevel(9, 1);assertThrows(IllegalArgumentException.class, () -> {game.addSquare(new BlankSquare(), 22, 0);});}@Testvoid testColoursAreAsAdded() {setup();Color[] expectedColors = { Color.BLUE, Color.RED, Color.YELLOW,Color.GREEN, Color.BLANK, Color.PURPLE };Color[] actualColors = { game.getColorAt(2, 0), game.getColorAt(3, 0),game.getColorAt(4, 0),game.getColorAt(5, 0), game.getColorAt(7, 0),game.getColorAt(6, 0) };assertArrayEquals(expectedColors, actualColors);}@Testvoid testShapesAreAsAdded() {setup();Shape[] expectedShapes = { Shape.DIAMOND, Shape.CROSS, Shape.STAR,Shape.FLOWER, Shape.BLANK, Shape.LIGHTNING };Shape[] actualShapes = { game.getShapeAt(2, 0), game.getShapeAt(3, 0),game.getShapeAt(4, 0),game.getShapeAt(5, 0), game.getShapeAt(7, 0),game.getShapeAt(6, 0) };assertArrayEquals(expectedShapes, actualShapes);}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 10© Araimport static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.BeforeEach;import org.junit.jupiter.api.Test;class TestGameHoldsEyeball {Game game;@BeforeEachvoid add7High3WideLevel() throws Exception {game = new Game();game.addLevel(7, 3);}@Testvoid testAddingEyeballOutsideHeightThrowsException() {// this.add7High3WideLevel();assertThrows(IllegalArgumentException.class, () -> {game.addEyeball(9, 2, Direction.UP);});}@Testvoid testAddingEyeballOutsideWidthThrowsException() {// this.add7High3WideLevel();assertThrows(IllegalArgumentException.class, () -> {game.addEyeball(6, 5, Direction.UP);});}@Testvoid testAddingEyeballPutsItWhereExpected() {// this.add7High3WideLevel();game.addEyeball(4, 2, Direction.UP);int[] expectedRowColumn = { 4, 2 };int[] actualRowColumn = { game.getEyeballRow(),game.getEyeballColumn() };assertArrayEquals(expectedRowColumn, actualRowColumn);}@Testvoid testAddingEyeballFacingUpFacesUP() {// this.add7High3WideLevel();game.addEyeball(4, 2, Direction.UP);Direction expectedDirection = Direction.UP;Direction actualDirection = game.getEyeballDirection();assertEquals(expectedDirection, actualDirection);}@Testvoid testAddingEyeballFacingDOWNFacesDOWN() {// this.add7High3WideLevel();game.addEyeball(4, 2, Direction.DOWN);Direction expectedDirection = Direction.DOWN;Direction actualDirection = game.getEyeballDirection();assertEquals(expectedDirection, actualDirection);}@Testvoid testAddingEyeballFacingLEFTFacesLEFT() {// this.add7High3WideLevel();game.addEyeball(4, 2, Direction.LEFT);Direction expectedDirection = Direction.LEFT;Direction actualDirection = game.getEyeballDirection();assertEquals(expectedDirection, actualDirection);}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 11© Ara@Testvoid testAddingEyeballFacingRIGHTFacesRIGHT() {// this.add7High3WideLevel();game.addEyeball(4, 2, Direction.RIGHT);Direction expectedDirection = Direction.RIGHT;Direction actualDirection = game.getEyeballDirection();assertEquals(expectedDirection, actualDirection);}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 12© Araimport static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.BeforeEach;import org.junit.jupiter.api.Test;class TestUpMoves {Game game;@BeforeEachvoid setUpVerticalLevel() throws Exception {game = new Game();game.addLevel(9, 1);game.addSquare(new PlayableSquare(Color.GREEN, Shape.STAR), 0, 0);game.addSquare(new BlankSquare(), 1, 0);game.addSquare(new PlayableSquare(Color.BLUE, Shape.DIAMOND), 2, 0);game.addSquare(new PlayableSquare(Color.RED, Shape.CROSS), 3, 0);game.addSquare(new PlayableSquare(Color.YELLOW, Shape.STAR), 4, 0);game.addSquare(new PlayableSquare(Color.GREEN, Shape.FLOWER), 5, 0);game.addSquare(new PlayableSquare(Color.GREEN, Shape.STAR), 6, 0);// each test needs to add the eyeball!!}@Testvoid testOkToMoveToSameColorOrShape() {boolean[] expected = { true, true };game.addEyeball(6, 0, Direction.UP);boolean[] actual = { game.canMoveTo(5, 0), game.canMoveTo(4, 0) };assertArrayEquals(expected, actual);}@Testvoid testNotOkToMovetoDifferentColorAndShape() {boolean[] expected = { false, false };game.addEyeball(6, 0, Direction.UP);boolean[] actual = { game.canMoveTo(2, 0), game.canMoveTo(3, 0) };assertArrayEquals(expected, actual);}@Testvoid testNoErrorMessageWhenMovingToSameColorOrShape() {Message[] expected = { Message.OK, Message.OK };game.addEyeball(6, 0, Direction.UP);Message[] actual = { game.MessageIfMovingTo(5, 0),game.MessageIfMovingTo(4, 0) };assertArrayEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingToDifferentColorAndShape() {Message[] expected = { Message.DIFFERENT_SHAPE_OR_COLOR,Message.DIFFERENT_SHAPE_OR_COLOR };game.addEyeball(6, 0, Direction.UP);Message[] actual = { game.MessageIfMovingTo(2, 0),game.MessageIfMovingTo(3, 0) };assertArrayEquals(expected, actual);}@Testvoid testOkWhenEyeballFacesRightOnMovingUp() {boolean expected = true;game.addEyeball(6, 0, Direction.RIGHT);boolean actual = game.isDirectionOK(5, 0);assertEquals(expected, actual);}@Testvoid testOkWhenEyeballFacesLeftOnMovingUp() {Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 13© Araboolean expected = true;game.addEyeball(6, 0, Direction.LEFT);boolean actual = game.isDirectionOK(5, 0);assertEquals(expected, actual);}@Testvoid testNotOkWhenMovingBackwards() {boolean expected = false;game.addEyeball(6, 0, Direction.DOWN);boolean actual = game.isDirectionOK(5, 0);assertEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingBackwards() {Message expected = Message.BACKWARDS_MOVE;game.addEyeball(6, 0, Direction.DOWN);Message actual = game.checkDirectionMessage(5, 0);assertEquals(expected, actual);}@Testvoid testNotOkWhenPathToDestinationCrossesBlank() {boolean expected = false;game.addEyeball(6, 0, Direction.UP);boolean actual = game.hasBlankFreePathTo(0, 0);assertEquals(expected, actual);}@Testvoid testErrorMessageWhenPathToDestinationCrossesBlank() {Message expected = Message.MOVING_OVER_BLANK;game.addEyeball(6, 0, Direction.UP);Message actual = game.checkMessageForBlankOnPathTo(0, 0);assertEquals(expected, actual);}@Testvoid testEyeballMovesToDestinationRowAndColumn() {int expectedRow = 4;int expectedColumn = 0;int[] expected = { expectedRow, expectedColumn };game.addEyeball(6, 0, Direction.UP);game.moveTo(4, 0);int[] actual = { game.getEyeballRow(), game.getEyeballColumn() };assertArrayEquals(expected, actual);}@Testvoid testEyeballFacesUPOnMovingUp() {Direction expectedDirection = Direction.UP;game.addEyeball(6, 0, Direction.RIGHT);game.moveTo(4, 0);Direction actualDirection = game.getEyeballDirection();assertEquals(expectedDirection, actualDirection);}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 14© Araimport static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.BeforeEach;import org.junit.jupiter.api.Test;class TestLeftMoves {Game game;@BeforeEachvoid setUpVerticalLevel() throws Exception {game = new Game();game.addLevel(1, 9);game.addSquare(new PlayableSquare(Color.GREEN, Shape.STAR), 0, 0);game.addSquare(new BlankSquare(), 0, 1);game.addSquare(new PlayableSquare(Color.BLUE, Shape.DIAMOND), 0, 2);game.addSquare(new PlayableSquare(Color.RED, Shape.CROSS), 0, 3);game.addSquare(new PlayableSquare(Color.YELLOW, Shape.STAR), 0, 4);game.addSquare(new PlayableSquare(Color.GREEN, Shape.FLOWER), 0, 5);game.addSquare(new PlayableSquare(Color.GREEN, Shape.STAR), 0, 6);// each test needs to add the eyeball!!}@Testvoid testOkToMoveToSameColorOrShape() {boolean[] expected = { true, true };game.addEyeball(0, 6, Direction.LEFT);boolean[] actual = { game.canMoveTo(0, 5), game.canMoveTo(0, 4) };assertArrayEquals(expected, actual);}@Testvoid testNotOkToMovetoDifferentColorAndShape() {boolean[] expected = { false, false };game.addEyeball(0, 6, Direction.LEFT);boolean[] actual = { game.canMoveTo(0, 2), game.canMoveTo(0, 3) };assertArrayEquals(expected, actual);}@Testvoid testNoErrorMessageWhenMovingToSameColorOrShape() {Message[] expected = { Message.OK, Message.OK };game.addEyeball(0, 6, Direction.LEFT);Message[] actual = { game.MessageIfMovingTo(0, 5),game.MessageIfMovingTo(0, 4) };assertArrayEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingToDifferentColorAndShape() {Message[] expected = { Message.DIFFERENT_SHAPE_OR_COLOR,Message.DIFFERENT_SHAPE_OR_COLOR };game.addEyeball(0, 6, Direction.LEFT);Message[] actual = { game.MessageIfMovingTo(0, 2),game.MessageIfMovingTo(0, 3) };assertArrayEquals(expected, actual);}@Testvoid testOkWhenEyeballFacesDownOnMovingLeft() {boolean expected = true;game.addEyeball(0, 6, Direction.DOWN);boolean actual = game.isDirectionOK(0, 5);assertEquals(expected, actual);}@Testvoid testOkWhenEyeballFacesUpOnMovingLeft() {Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 15© Araboolean expected = true;game.addEyeball(0, 6, Direction.UP);boolean actual = game.isDirectionOK(0, 5);assertEquals(expected, actual);}@Testvoid testNotOKWhenMovingBackwards() {boolean expected = false;game.addEyeball(0, 6, Direction.RIGHT);boolean actual = game.isDirectionOK(0, 5);assertEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingBackwards() {Message expected = Message.BACKWARDS_MOVE;game.addEyeball(0, 6, Direction.RIGHT);Message actual = game.checkDirectionMessage(0, 5);assertEquals(expected, actual);}@Testvoid testNotOKWhenPathToDestinationCrossesBlank() {boolean expected = false;game.addEyeball(0, 6, Direction.LEFT);boolean actual = game.hasBlankFreePathTo(0, 0);assertEquals(expected, actual);}@Testvoid testErrorMessageWhenPathToDestinationCrossesBlank() {Message expected = Message.MOVING_OVER_BLANK;game.addEyeball(0, 6, Direction.LEFT);Message actual = game.checkMessageForBlankOnPathTo(0, 0);assertEquals(expected, actual);}@Testvoid testEyeballMovesToDestinationRowAndColumn() {int expectedRow = 0;int expectedColumn = 4;int[] expected = { expectedRow, expectedColumn };game.addEyeball(0, 6, Direction.LEFT);game.moveTo(0, 4);int[] actual = { game.getEyeballRow(), game.getEyeballColumn() };assertArrayEquals(expected, actual);}@Testvoid testEyeballFacesLeftOnMovingLeft() {Direction expectedDirection = Direction.LEFT;game.addEyeball(0, 6, Direction.UP);game.moveTo(0, 4);Direction actualDirection = game.getEyeballDirection();assertEquals(expectedDirection, actualDirection);}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 16© Araimport static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.BeforeEach;import org.junit.jupiter.api.Test;class TestDownMoves {Game game;@BeforeEachvoid setUpVerticalLevel() throws Exception {game = new Game();game.addLevel(9, 1);game.addSquare(new PlayableSquare(Color.GREEN, Shape.STAR), 0, 0);game.addSquare(new PlayableSquare(Color.GREEN, Shape.FLOWER), 1, 0);game.addSquare(new PlayableSquare(Color.YELLOW, Shape.STAR), 2, 0);game.addSquare(new PlayableSquare(Color.RED, Shape.CROSS), 3, 0);game.addSquare(new PlayableSquare(Color.BLUE, Shape.DIAMOND), 4, 0);game.addSquare(new PlayableSquare(Color.YELLOW, Shape.FLOWER), 5, 0);game.addSquare(new BlankSquare(), 6, 0);game.addSquare(new PlayableSquare(Color.GREEN, Shape.STAR), 7, 0);game.addSquare(new PlayableSquare(Color.RED, Shape.FLOWER), 8, 0);// each test needs to add the eyeball!!}@Testvoid testOkToMoveToSameColorOrShape() {boolean[] expected = { true, true };game.addEyeball(0, 0, Direction.DOWN);boolean[] actual = { game.canMoveTo(1, 0), game.canMoveTo(2, 0) };assertArrayEquals(expected, actual);}@Testvoid testNotOkToMoveToDifferentColorAndShape() {boolean[] expected = { false, false };game.addEyeball(0, 0, Direction.DOWN);boolean[] actual = { game.canMoveTo(3, 0), game.canMoveTo(5, 0) };assertArrayEquals(expected, actual);}@Testvoid testNoErrorMessageWhenMovingToSameColorOrShape() {Message[] expected = { Message.OK, Message.OK };game.addEyeball(0, 0, Direction.DOWN);Message[] actual = { game.MessageIfMovingTo(1, 0),game.MessageIfMovingTo(2, 0) };assertArrayEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingToDifferentColorAndShape() {Message[] expected = { Message.DIFFERENT_SHAPE_OR_COLOR,Message.DIFFERENT_SHAPE_OR_COLOR };game.addEyeball(0, 0, Direction.DOWN);Message[] actual = { game.MessageIfMovingTo(3, 0),game.MessageIfMovingTo(5, 0) };assertArrayEquals(expected, actual);}@Testvoid testOkWhenEyeballFacesRightOnMovingDown() {boolean expected = true;game.addEyeball(0, 0, Direction.RIGHT);boolean actual = game.isDirectionOK(2, 0);assertEquals(expected, actual);}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 17© Ara@Testvoid testOkWhenEyeballFacesLeftOnMovingDown() {boolean expected = true;game.addEyeball(0, 0, Direction.LEFT);boolean actual = game.isDirectionOK(2, 0);assertEquals(expected, actual);}@Testvoid testNotOkWhenMovingBackwards() {boolean expected = false;game.addEyeball(0, 0, Direction.UP);boolean actual = game.isDirectionOK(2, 0);assertEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingBackwards() {Message expected = Message.BACKWARDS_MOVE;game.addEyeball(0, 0, Direction.UP);Message actual = game.checkDirectionMessage(2, 0);assertEquals(expected, actual);}@Testvoid testNotOkWhenPathToDestinationCrossesBlank() {boolean expected = false;game.addEyeball(1, 0, Direction.DOWN);boolean actual = game.hasBlankFreePathTo(7, 0);assertEquals(expected, actual);}@Testvoid testErrorMessageWhenPathToDestinationCrossesBlank() {Message expected = Message.MOVING_OVER_BLANK;game.addEyeball(1, 0, Direction.DOWN);Message actual = game.checkMessageForBlankOnPathTo(7, 0);assertEquals(expected, actual);}@Testvoid testEyeballMovesToDestinationRowAndColumn() {int expectedRow = 5;int expectedColumn = 0;int[] expected = { expectedRow, expectedColumn };game.addEyeball(1, 0, Direction.DOWN);game.moveTo(5, 0);int[] actual = { game.getEyeballRow(), game.getEyeballColumn() };assertArrayEquals(expected, actual);}@Testvoid testEyeballFacesDownOnMovingDown() {Direction expectedDirection = Direction.DOWN;game.addEyeball(1, 0, Direction.RIGHT);game.moveTo(5, 0);Direction actualDirection = game.getEyeballDirection();assertEquals(expectedDirection, actualDirection);}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 18© Araimport static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.BeforeEach;import org.junit.jupiter.api.Test;class TestRightMoves {Game game;@BeforeEachvoid setUpVerticalLevel() throws Exception {game = new Game();game.addLevel(1, 9);game.addSquare(new PlayableSquare(Color.GREEN, Shape.STAR), 0, 0);game.addSquare(new PlayableSquare(Color.GREEN, Shape.FLOWER), 0, 1);game.addSquare(new PlayableSquare(Color.YELLOW, Shape.STAR), 0, 2);game.addSquare(new PlayableSquare(Color.RED, Shape.CROSS), 0, 3);game.addSquare(new PlayableSquare(Color.BLUE, Shape.DIAMOND), 0, 4);game.addSquare(new BlankSquare(), 0, 5);game.addSquare(new PlayableSquare(Color.GREEN, Shape.STAR), 0, 6);// each test needs to add the eyeball!!}@Testvoid testOkToMoveToSameColorOrShape() {boolean[] expected = { true, true };game.addEyeball(0, 0, Direction.RIGHT);boolean[] actual = { game.canMoveTo(0, 1), game.canMoveTo(0, 2) };assertArrayEquals(expected, actual);}@Testvoid testNotOkToMovetoDifferentColorAndShape() {boolean[] expected = { false, false };game.addEyeball(0, 0, Direction.RIGHT);boolean[] actual = { game.canMoveTo(0, 3), game.canMoveTo(0, 4) };assertArrayEquals(expected, actual);}@Testvoid testNoErrorMessageWhenMovingToSameColorOrShape() {Message[] expected = { Message.OK, Message.OK };game.addEyeball(0, 0, Direction.RIGHT);Message[] actual = { game.MessageIfMovingTo(0, 1),game.MessageIfMovingTo(0, 2) };assertArrayEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingToDifferentColorAndShape() {Message[] expected = { Message.DIFFERENT_SHAPE_OR_COLOR,Message.DIFFERENT_SHAPE_OR_COLOR };game.addEyeball(0, 0, Direction.RIGHT);Message[] actual = { game.MessageIfMovingTo(0, 3),game.MessageIfMovingTo(0, 4) };assertArrayEquals(expected, actual);}@Testvoid testOkWhenEyeballFacesDownOnMovingRight() {boolean expected = true;game.addEyeball(0, 0, Direction.DOWN);boolean actual = game.isDirectionOK(0, 2);assertEquals(expected, actual);}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 19© Ara@Testvoid testOkWhenEyeballFacesUpOnMovingRight() {boolean expected = true;game.addEyeball(0, 0, Direction.UP);boolean actual = game.isDirectionOK(0, 2);assertEquals(expected, actual);}@Testvoid testNotOKWhenMovingBackwards() {boolean expected = false;game.addEyeball(0, 0, Direction.LEFT);boolean actual = game.isDirectionOK(0, 2);assertEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingBackwards() {Message expected = Message.BACKWARDS_MOVE;game.addEyeball(0, 0, Direction.LEFT);Message actual = game.checkDirectionMessage(0, 2);assertEquals(expected, actual);}@Testvoid testNotOKWhenPathToDestinationCrossesBlank() {boolean expected = false;game.addEyeball(0, 0, Direction.RIGHT);boolean actual = game.hasBlankFreePathTo(0, 6);assertEquals(expected, actual);}@Testvoid testErrorMessageWhenPathToDestinationCrossesBlank() {Message expected = Message.MOVING_OVER_BLANK;game.addEyeball(0, 0, Direction.RIGHT);Message actual = game.checkMessageForBlankOnPathTo(0, 6);assertEquals(expected, actual);}@Testvoid testEyeballMovesToDestinationRowAndColumn() {int expectedRow = 0;int expectedColumn = 2;int[] expected = { expectedRow, expectedColumn };game.addEyeball(0, 0, Direction.RIGHT);game.moveTo(0, 2);int[] actual = { game.getEyeballRow(), game.getEyeballColumn() };assertArrayEquals(expected, actual);}@Testvoid testEyeballFacesRightOnMovingRight() {Direction expectedDirection = Direction.RIGHT;game.addEyeball(0, 0, Direction.DOWN);game.moveTo(0, 2);Direction actualDirection = game.getEyeballDirection();assertEquals(expectedDirection, actualDirection);}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 20© Araimport java.util.Random;import static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.BeforeEach;import org.junit.jupiter.api.Test;class TestDiagonalMoves {Game game;Random rand;@BeforeEachvoid setUpVerticalLevel() throws Exception {game = new Game();game.addLevel(10, 10);// each test needs to add the eyeball!!rand = new Random();}@Testvoid testNotOkWhenMovingToUpLeft() {boolean expected = false;game.addEyeball(9, 9, Direction.UP);boolean actual = game.isDirectionOK(rand.nextInt(9), rand.nextInt(9));assertEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingToUpLeft() {Message expected = Message.MOVING_DIAGONALLY;game.addEyeball(9, 9, Direction.UP);Message actual = game.checkDirectionMessage(rand.nextInt(9),rand.nextInt(9));assertEquals(expected, actual);}@Testvoid testNotOkWhenMovingToUpRight() {boolean expected = false;game.addEyeball(9, 0, Direction.RIGHT);boolean actual = game.isDirectionOK(rand.nextInt(9), rand.nextInt(9) +1);assertEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingToUpRight() {Message expected = Message.MOVING_DIAGONALLY;game.addEyeball(9, 0, Direction.RIGHT);Message actual = game.checkDirectionMessage(rand.nextInt(9),rand.nextInt(9) + 1);assertEquals(expected, actual);}@Testvoid testNotOkWhenMovingToDownRight() {boolean expected = false;game.addEyeball(0, 0, Direction.DOWN);boolean actual = game.isDirectionOK(rand.nextInt(9) + 1,rand.nextInt(9) + 1);assertEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingToDownRight() {Message expected = Message.MOVING_DIAGONALLY;game.addEyeball(0, 0, Direction.DOWN);Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 21© AraMessage actual = game.checkDirectionMessage(rand.nextInt(9) + 1,rand.nextInt(9) + 1);assertEquals(expected, actual);}@Testvoid testNotOkWhenMovingToDownLeft() {boolean expected = false;game.addEyeball(0, 9, Direction.LEFT);boolean actual = game.isDirectionOK(rand.nextInt(9) + 1,rand.nextInt(9));assertEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingToDownLeft() {Message expected = Message.MOVING_DIAGONALLY;game.addEyeball(0, 9, Direction.LEFT);Message actual = game.checkDirectionMessage(rand.nextInt(9) + 1,rand.nextInt(9));assertEquals(expected, actual);}@Testvoid testNotOkWhenMovingBackwards() {boolean expected = false;game.addEyeball(0, 9, Direction.UP);boolean actual = game.isDirectionOK(rand.nextInt(9) + 1,rand.nextInt(9));assertEquals(expected, actual);}@Testvoid testGetsErrorMessageWhenMovingBackwards() {Message expected = Message.MOVING_DIAGONALLY;game.addEyeball(0, 9, Direction.UP);Message actual = game.checkDirectionMessage(rand.nextInt(9) + 1,rand.nextInt(9));assertEquals(expected, actual);}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 22© Araimport static org.junit.jupiter.api.Assertions.*;import org.junit.jupiter.api.Test;class TestCompletingGoals {Game game;LevelDataHandler levelDataHandler;record SquareData(Color color, Shape shape, Position position) {};SquareData[] levelOneInitData = {new SquareData(Color.BLANK, Shape.BLANK, new Position(0, 0)),new SquareData(Color.BLANK, Shape.BLANK, new Position(0, 1)),new SquareData(Color.RED, Shape.FLOWER, new Position(0, 2)),new SquareData(Color.BLANK, Shape.BLANK, new Position(0, 3)),new SquareData(Color.BLUE, Shape.CROSS, new Position(1, 0)),new SquareData(Color.YELLOW, Shape.FLOWER, new Position(1, 1)),new SquareData(Color.YELLOW, Shape.DIAMOND, new Position(1,2)),new SquareData(Color.GREEN, Shape.CROSS, new Position(1, 3)),new SquareData(Color.GREEN, Shape.FLOWER, new Position(2, 0)),new SquareData(Color.RED, Shape.STAR, new Position(2, 1)),new SquareData(Color.GREEN, Shape.STAR, new Position(2, 2)),new SquareData(Color.YELLOW, Shape.DIAMOND, new Position(2,3)),new SquareData(Color.RED, Shape.FLOWER, new Position(3, 0)),new SquareData(Color.BLUE, Shape.FLOWER, new Position(3, 1)),new SquareData(Color.RED, Shape.STAR, new Position(3, 2)),new SquareData(Color.GREEN, Shape.FLOWER, new Position(3, 3)),new SquareData(Color.BLUE, Shape.STAR, new Position(4, 0)),new SquareData(Color.RED, Shape.DIAMOND, new Position(4, 1)),new SquareData(Color.BLUE, Shape.FLOWER, new Position(4, 2)),new SquareData(Color.BLUE, Shape.DIAMOND, new Position(4, 3)),new SquareData(Color.BLANK, Shape.BLANK, new Position(5, 0)),new SquareData(Color.BLUE, Shape.DIAMOND, new Position(5, 1)),new SquareData(Color.BLANK, Shape.BLANK, new Position(5, 2)),new SquareData(Color.BLANK, Shape.BLANK, new Position(5, 3)) };Position[] levelOneSolution = {new Position(3, 1), new Position(3, 3), new Position(1, 3), newPosition(1, 0),new Position(4, 0), new Position(4, 2), new Position(0, 2) };private class LevelDataHandler {Game game;public LevelDataHandler(Game game) {this.game = game;}public void createLevel(int height, int width) {this.game.addLevel(height, width);}public void setUpLevel(SquareData[] levelInitData) {for (SquareData s : levelInitData) {Square square;if ((s.color == Color.BLANK) && (s.shape ==Shape.BLANK)) {square = new BlankSquare();} else {square = new PlayableSquare(s.color, s.shape);}this.game.addSquare(square, s.position.getRow(),s.position.getColumn());}}Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 23© Ara}private void setUpLevelOne() {game = new Game();levelDataHandler = new LevelDataHandler(game);levelDataHandler.createLevel(6, 4);levelDataHandler.setUpLevel(levelOneInitData);game.addGoal(0, 2);game.addEyeball(5, 1, Direction.UP);}@Testvoid testCompletingLevelOne() {setUpLevelOne();for (Position p : levelOneSolution) {game.moveTo(p.getRow(), p.getColumn());}int expectedCompletedGoalCount = 1;int actualGoalCount = game.getCompletedGoalCount();assertEquals(expectedCompletedGoalCount, actualGoalCount);}private void add10High1WideLevel() {game = new Game();game.addLevel(10, 1);game.addSquare(new PlayableSquare(Color.YELLOW, Shape.STAR), 4, 0);game.addSquare(new PlayableSquare(Color.RED, Shape.CROSS), 5, 0);game.addSquare(new PlayableSquare(Color.GREEN, Shape.STAR), 6, 0);game.addSquare(new PlayableSquare(Color.BLUE, Shape.DIAMOND), 7, 0);game.addSquare(new PlayableSquare(Color.GREEN, Shape.FLOWER), 8, 0);game.addEyeball(4, 0, Direction.LEFT);game.addGoal(6, 0);}@Testvoid testOkToMoveToAGoalWithSameColorOrShape() {add10High1WideLevel();assertTrue(game.canMoveTo(6, 0));}@Testvoid testNoErrorMessageWhenMovingToAGoalWithSameColorOrShape() {add10High1WideLevel();Message expected = Message.OK;Message actual = game.MessageIfMovingTo(6, 0);assertEquals(expected, actual);}@Testvoid testNotOkToMoveToAGoalWithDifferentColorOrShape() {add10High1WideLevel();game.addGoal(8, 0);assertFalse(game.canMoveTo(8, 0));}@Testvoid testGetsErrorMessageWhenMovingToAGoalWithDifferentColorOrShape() {add10High1WideLevel();Message expected = Message.DIFFERENT_SHAPE_OR_COLOR;game.addGoal(8, 0);Message actual = game.MessageIfMovingTo(8, 0);Education and Applied Research Division Department of Enterprise and Digital InnovationBCDE223 Assessment 2 2021S1 V8.docx Page 24© AraassertEquals(expected, actual);}@Testvoid testNotOkToMoveToAGoalAtADiagonalSquare() {setUpLevelOne();game.addGoal(2, 3);assertFalse(game.canMoveTo(2, 3));}@Testvoid testNotOkWhenMovingBackwardsToAGoalWithSameColorOrShape() {setUpLevelOne();game.addGoal(3, 0);game.moveTo(3, 1);game.moveTo(3, 3);assertFalse(game.canMoveTo(3, 0));}@Testvoid testCompleting1GoalIncreasesCompletedGoalCountBy1() {add10High1WideLevel();int expectedCompletedGoalCount = game.getCompletedGoalCount() + 1;game.moveTo(6, 0);int actualCompletedGoalCount = game.getCompletedGoalCount();assertEquals(expectedCompletedGoalCount, actualCompletedGoalCount);}@Testvoid testCompleting1GoalDecreaseGoalCountBy1() {add10High1WideLevel();int expectedGoalCount = game.getGoalCount() – 1;game.moveTo(6, 0);int actualGoalCount = game.getGoalCount();assertEquals(expectedGoalCount, actualGoalCount);}@Testvoid testGoalWillBeRemovedFromSquareAfterCompletingTheGoal() {add10High1WideLevel();game.moveTo(6, 0);assertFalse(game.hasGoalAt(6, 0));}@Testvoid testGoalSquareWillNotBeChangedWhenEyeballMovesOntoIt() {add10High1WideLevel();String[] expected = { “GREEN”, “STAR” };game.moveTo(6, 0);String[] actual = { game.getColorAt(6, 0).name(), game.getShapeAt(6,0).name() };assertArrayEquals(expected, actual);}@Testvoid testGoalSquareBecomesBlankSquareAfterEyeballMovesToAnotherSquare() {add10High1WideLevel();game.moveTo(6, 0);game.moveTo(8, 0);String[] expected = { “BLANK”, “BLANK” };String[] actual = { game.getColorAt(6, 0).name(), game.getShapeAt(6,0).name() };assertArrayEquals(expected, actual);}}

QUALITY: 100% ORIGINAL PAPER – NO PLAGIARISM – CUSTOM PAPER

Leave a Reply

Your email address will not be published. Required fields are marked *