ICT221 Java Programming Assignment
ICT221 Java Programming Assignment
422910034889600This is Task 2 of ICT221, which is worth 40% of the course. Your solution must be clearly separated into two separate parts, in separate Java packages:
Part 1: (in package savekoalas.engine): your Game Engine classes with Unit Tests.
Part 2: (in package savekoalas.gui): a JavaFX GUI that allows users to play your game.
3436339465257http://www.zorsay.com/question/23/Suggest-some-good-fun-and-educational-board-games-to-gift-for-a-10-year-old-for-his-birthday
00http://www.zorsay.com/question/23/Suggest-some-good-fun-and-educational-board-games-to-gift-for-a-10-year-old-for-his-birthday
After you create the project in GitHub classroom, two packages will be created automatically. Please keep that code structure unchanged.
SaveKoalas Game Description
SaveKoalas is a 2D game in a 10 x 10 grid maze map. Unfortunately, because of bushfire, the map will be in fire after a time limit. The goal is to move the player to save all koalas in the map and leave the map at the exit door within the time limit.
To simplify the design, we assume each movement, or a step, of the play equals to one time unit. The maze map consists of the following items:
An entrance to the maze, which is located at the bottom left grid.
An exit of the maze, which is located at the top right grid.
A player, who is place at the entrance at the beginning of a game.
5 koalas, each of which is placed at a random grid.
Some traps, each of which is placed at a random grid. Once in a trap, the player needs to use 10 steps to move out of the trap.
Some magic fountains, each of which is placed at a random grid. Visiting/consuming a fountain can increase time limit by 6.
The followings are its key features and settings.
To start a new game:
The player input an integer d, the difficulty level of the game. d should be in the range of 0 10, and it has the default value of 5.
The player clicks a Run button to start the game, which triggers the random generation of the map.
Random generation of the map:
An entrance cell is placed at the bottom left cell.
An exit cell is placed at the top right cell.
A time limit, which is initially set up as 200 steps.
The player will appear in the entrance cell with the step counter as 0.
5 koalas are placed randomly in the map.
d traps are placed randomly in the map.
(10 - d) fountains are placed randomly in the map.
The entrance, exit, koalas, traps, and fountains should not overlap.
To play a game:
The player can move in 4 directions: left, right, up, and down inside the map. Each movement is considered as 1 step, unless stated otherwise.
Moving out of a trap uses 10 steps. The trap remains there after the visit.
Visiting a fountain increases the time limit by 6. After the visit, the fountain is consumed, and the cell becomes empty.
Visiting a koala saves 1 koala. The koala is picked up, and the cell becomes empty.
The game finishes when
(Win) The player saves all 5 koalas and is at the exit cell. The score is: (time limit steps of the player).
(Lose) The time limit has reached. The score is -1.
The score is shown at the end of a game.
Other requirements:
The game can be played in the text UI in which the interaction is enabled by typing keywords, e.g. u for up and d for down.
In the game, different items should be displayed with different icons/symbols.
Time limit of the map is displayed and updated during the play.
Steps of the player is displayed and updated during the play.
The number of saved koalas is displayed and updated during the play.
In the GUI, a player can play by clicking 4 control buttons.
In the GUI, a Help button to get instructions on the game play.
In the GUI, a Save button to save the game play as a .txt file.
In the GUI, a Load button to load a saved game.
It is recommended that you implement the 'engine' of the game first. You should write some unit tests to check that your game logic works correctly.
Then you can use JavaFX to add a graphical user interface (GUI) to your game, which displays the 2D board and allows the user to play the game. You MUST use JavaFX, not any other Java GUI libraries. Otherwise, the GUI part will be marked as 0.
Learning Objectives
Learn to use object-oriented design (OOD) to design Java programs;
Be able to use inheritance/interface and subtyping relationships between classes;Be able to use association or composition relationships between classes;
Be able to develop a comprehensive suite of unit tests for the core logic classes of an application (e.g., for the game engine);
Build simple graphical user interfaces using JavaFX.
Part 1: Game Engine (Weeks 9-11)
Set up your Git Repository. Follow the assessment link in Github Classroom (https://classroom.github.com/a/9bJy0LH1) to automatically create your own private GitHub repository containing one module with two packages: savekoalas.engine and savekoalas.gui.
Clone this repository onto your computer using IntelliJ.
Make sure you also have Java JDK 15 or later installed on your computer.
Check you can run JavaFX. This project uses the 'Gradle' build tool to automatically download and install the necessary JavaFX and JUnit libraries when you build and run the project.
After the build is complete, right-click on "src/main/java/savekoalas/gui/RunGame" and do Run RunGame.main(). You should see a blank JavaFX GUI pop up. Use this RunGame class every time you want to run your GUI.
Data Design Decisions: Think carefully about whether each cell in your map should be a primitive value (like an integer or an enum value), or should it be an object? Using objects is more flexible, since it allows you to use Java subtyping to make different cells have different behaviour.
Implement and Test Your Game Engine: GameEngine.java is provided as the base for engine development. You need to add more details to it, and you may also want to add other class files in the savekoalas.engine package to support the engine development. TDD is recommended, but not necessary, to develop your unit tests and game engine at the same time, in parallel. Recall: Write a test for each new feature and check that it fails, then implement that feature in your engine classes and rerun the test to check that it now passes. Repeat You can refactor (rename and reorganise) your code at any stage, if you see a way of making it simpler and more elegant. By the time you have finished implementing your game engine, one (or several) of your tests should be stepping through a complete game from start to end, calling the methods of your engine API and checking the results, including the game win/lose verdict at the end.
Text-based play: The main() method of GameEngine class should support a text-based game play in the console.
Class Relationships: To get high marks, your engine needs to include several Java classes, with some association/composition relationships between them, and if possible, some inheritance/interface usage. Think about where you can best use these Java features.
Part 2: Game GUI (Weeks 12-13)
The goal of this stage is to use JavaFX to add an elegant and fully functional GUI to your game so that it can more easily be played on desktop computers. Your GUI should have the following features:
event-handling of mouse events, including buttons for starting game and moving up/down/left/right;display of bitmap images (I recommend you use some large images for the background of the whole game, and use some small images for different items/cells in the map, so that the game looks professional and entertaining);multiple panels, with a main gaming panel to display the game, plus one or more panels around the edges to display game options, score information, and control and help buttons etc.;
a clean separation between the back-end (game engine) and front-end (GUI) classes using different Java package names, as described above;
Start by drawing one or two paper sketches of the GUI you plan to build. Take a photo of each sketch, as you will need to include these in your final report.
Submission and Marking Criteria
You must submit a single Microsoft Word Report to Canvas, based on the report template given in the Assessment / Task 2 area on Canvas. You do NOT need to submit your code, as we already have access to your GitHub repository. You are reminded that your submission must be completely your own individual work, in your own words, and you must correctly reference any external sources that you use in your report, or in your code.
Your submission will be marked using the following criteria:
[40%] Game Engine functionality and code: this will be marked using the following criteria. Functionality: A playable and robust game with console input. Code: Good OOD of the game engine classes with strong encapsulation of the data fields within classes; correct implementation of association or composition relationships between classes; good use of inheritance/interface and subtype polymorphism; good choice of data structures; adherence to recommended Java coding style (naming conventions, code formatting etc.); and concise elegant code with no duplicated code.
[15%] Game Engine JUnit Tests: these tests will be marked according to: how thoroughly they test all the Game Engine classes; and how well they follow correct JUnit naming conventions (eg. tests of mygame.engine.Foo.java should be in the Java source file mygame.engine.FooTest.java). Unit tests are optional for the following methods: constructors, setters, getters, and methods that simply print text to the console.
[25%] GUI functionality and code: this will be marked using the following criteria. Functionality: A playable and robust game with GUI interface; good use of JavaFX widgets, layout panes, and controls to build an elegant and functional user interface; appropriate use of bitmap images in the GUI; and saving/loading of games states. Code: Good use of event-driven programming; good OOD of the GUI classes with strong encapsulation of the data fields within classes; good use of inheritance/interface and subtype polymorphism; adherence to recommended Java coding style (naming conventions, code formatting etc.); concise elegant code with no duplicated code; and good use of exception handling to catch and report any I/O or game errors. This will also demonstrate that your textual user interface still works after you have added the GUI.
[20%] Documentation (Report.docx): this should contain four sections with 500-1000 words:
Introduction: one paragraph to explain what your game does, how a player can win the game, what features you implemented, etc.
Your UML diagram: that shows full details of all your game engine classes, plus the GUI classes that you have written. It should also show the main JavaFX classes you have used (just the class name is enough you do not need to include all their data fields and methods!), and the relationships between them and your classes. You do not need to include your unit testing classes in your UML diagram.
GUI sketches: that shows your original ideas for the GUI you plan to build for your game. This should be drawn by hand and then scanned or photographed and inserted into the Microsoft Word document. It just needs to be a rough sketch, possibly with some labels to show the contents of each panel or the function of certain buttons, if that is not obvious.
Reflection: a brief discussion of what went well in your game development, any difficulties that you encountered, and what you would do differently if you were doing it again.
 
								