Develop and test a software application

Assignment Help JAVA Programming
Reference no: EM132639708

COIT20256 Data Structures and Algorithms - Central Queensland University

Objectives

In this assignment, you are required to design, develop and test a software application that employs a Graphical User Interface (GUI) developed using JavaFXand a graph data structure which is configured from a database.

This assignment must be implemented:
1. incrementally according to the phases specified in this documentation.
2. according to the design given in these specifications. Make sure your assignment corresponds to the class diagrams and descriptionsof the methods and classes given in this document.

Background - The Task

In an adventure game, the user normally explores a world encountering treasure, magical creatures, monsters and obstacles to be overcome, often with an ultimate quest to be achieved.
In this assignment you are going to start the development of a simple screen-based adventure game by adding the functionality to build the layout of the world to be explored and providing the user with the ability to move around and explore this world using simple text-based commands entered througha GUI.
In our adventure theworld consistsof rooms connected to other rooms throughdoors. Each room will have a unique id (a number stored as a String), a simple description of the room, a description of items in the room and a list of the doors to other rooms.
In our simple adventure, the user can enter the following basic commands to explore the world:
• enter n - which allows the user to enter room n, if there is a door to room n from the current location. If there is no door to room n from the current location, enter n results in an error message followed by the description of the current room which includesthe list of the rooms that can be accessed through doors from the current location. When the user enters a new room, the user will be told which room has been entered followed by the brief description of the room.
• search- this provides a more detailed description of the room and any items present in the room.
• describe - repeats the initial description of the room plus the list of doors to adjacent rooms.
• goto n - is a magical teleportation command that can take you to any room in the world from any location (assuming that such a room exists). If no such room exists, an error message is displayed.
Future development could have rooms with monsters you have to fight, treasure you can collect, traps, magical creatures that interact with you in some way, maintenance of the user attributes (inventory, strength ...)and additional commands to collect treasure, fight monsters etc., but for this assignment we restrict ourselves to the above list of commands. The initial descriptions of the rooms and their more detailed contents is also very simplistic and limited to description 1 for room 1 etc. This is appropriate for testing the application. In an actual game you would have much more imaginative descriptions for your rooms and their contents.

Phase 1:
Call your application Adventure.
In phase 1 of the assignment you are to use JavaFX and SceneBuilder to develop the GUI described above and to include the code to implement the following behaviours:
• Clicking the Help Button is to result in the display of the valid commands in the text area (see screenshot below).
• Clicking the Exit Button is to result in program termination.
• Entering a command in the "command" text fieldfollowed by the <ENTER> key is to display the command that was entered in the text area. In a subsequent phase this action will be replaced with the required behavior for the command that was entered.

Hints:
1. For the text field specify the action listener name in the same way as for the buttons. When the <ENTER> key is pressed in the text field, an action event will be generated.
2. Use the selectAll() method with the textField to make it easier for the user to enter the next command.

Phase 2:
Build the graph data structure that corresponds to your "World map". It will consistof rooms and doors to adjacent rooms.

Nodes in the graph (Rooms)
Each node of the graph is to be an instance of a Roomclass.

The Room class has the following private attributes:
String roomID; //the unique room id represented as a String
String initialDescription;//the initial room description
String searchDescription; //the more detailed description after
//the user searches the room
ArrayList<Door> doors;//a list of all the doors (or graph edges)
//that can be accessed from this room

Edges in the graph (Doors)
Each edge is to be an instance of a Door class.
The Door class has the following private attributes:
String from; // the "from" room - this will be the current room
String to: // the "to" room - this is the room that this door
// will take you to

Note that the doors/edges have a direction. This means that for the door to allow you to go in both directions, both rooms involved must have the door to the other room in their edge list. Note it is possible that some doors are only one-way.
An example of a normal bi-directional door between room 1 and room 11 would mean that
1. Room 1 will have a door edge in its ArrayListthat has a from attribute of "1" and ato attribute of "11". All the room 1 edges (or doors) will have a from attributre of "1".
2. Room 11 will have a door edge in its ArrayList that has a from attribute of "11" and ato attribute of "1". All the room 11 edges (or doors) will have a from attribute of "11".
The Graph
We will implement our graph in a World class. This class will have the following private attributes:
HashMap<String, Room>map; //List of nodes (or rooms) in the
//world. The roomID is to be used as
//the key to access the room in the
//HashMap. The rooms will have a
// list of doors(edges) to other rooms

Room currentRoom; //keeps track of the user's current location

In phase 2 you are to initialize your graph using 4arrayswith the following data:
1. roomIDs - this array has all the roomIDs
2. roomDescriptions - this array has the basic description that will be displayed each time the user enters a room
3. searchDescriptions - this array has the more detailed descriptions of the room and the contents the user will see if they execute the search command. Note that more advanced implementations of the game could have various types of items or entities in the room (e.g. treasure, creatures etc.) and the room contents could change as the user interacts with the game.
4. Edges - this array will have two entries for every 2-way door indicating the from and to direction of the door/edge

To build the graph, develop the following loadMap() methodand invoke it from the World's constructor.
The loadMap() method
This method is to use the arrays described above to build the graph as follows:
1. Create a new HashMap and assign it to the World class'smap attribute (the instance variable that was declared asHashMap<String, Room>mapdiscussed above)
2. Use a for loop to Iterate through the data in the arrays (that contain thethe room data), creating a new Room and adding the new room to the HashMap using its roomID as the key to the HashMap.
For example, if you were just to add one room to the HashMap, you would use code similar to the following to create the new Room:
Room r = new Room( roomIDs[0], roomDescriptions[0], searchDescriptions[0] );
And then add this room to the HashMap use roomIDs[0] as the key. (Hint: use map's put() method)
3. Process the edges array to add the edges (or doors) to the edge (or doors) listfor each of the rooms. For example, the first element in edges is

{ "1", "11" }

This means that you have to add a door (or an edge) to the list of doors accessible from room "1" that will lead to room "11".

To add the door to the list of doors for a room:
o Get a reference to the room (in this example room "1") from the map(HashMap) you justcreated. (Hint: use map's get() method)
o Use the room's addDoor() method to add a door to room "11" (i.e. add a door from room "1" to room "11". The addDoor method is to create a newdoor (edge) and add it to the room's list of doors.

The UML diagram for the classes used to build the graph to represent the world:

To complete phase 2:
1. Complete the methods for World.java, Door.java and Room.java (see UML diagram above). Most of the methods should be self-explanatory. However, to avoid ambiguity, a brief description ofthree of the methods are given below:
a. The World's describe method is to invoke (or call) the current room's roomDescription methodand return the room description in response to a describe command being entered by the user.
b. The Room's roomDescriptionmethod is to return a String that has the basic room description as well as the list of doors that are accessible from that room. The searchDescription is not returned at this point.
c. The World's start method is to set the current room to the room with roomID of "1".
2. In the start() method in Adventure.java(i.e. in the file with main() and start()) create an instance of World and display the contents of your graph datastructure to check that it has been built correctly. Output the data structure to the standard output using World's displayMapData() method. In this phase, your start method should be similar to the following:

@Override
public void start(Stage stage) throws Exception {
FXMLLoader loader = new
FXMLLoader(getClass().getResource("FXMLDocument.fxml"));

Parent root = loader.load();

World map = new World();
System.out.println("Data in Map:");
map.displayMapData();

Scene scene = new Scene(root);

stage.setScene(scene);
stage.show();
}
Your output should be similar to the following, but with output for every room:

Phase 3:
The event handlers in the controller will require access to the graph data structure to perform their tasks. This means that youwill have to provide access to the data structure in the controller class in the same way that you did for question 3 in the week 4 tutorial.
Toachieve this:
1. In the controller class:
• Declare a member variable in the controller that is of type World.
• Write a startGame() method which
i. takes a parameter of type World and assigns it to the member variable in the controller class. This will give the controller access to the data structure with your world map.
ii. calls the map's start method which will set the current room to the first room.
iii. displays the appropriate messages to indicate the start of the game. It should welcome the user, describe the current room and display the help menu (see screenshot below).Note that only the basic room description and available doors are provided in the initial description when someone enters a room.
2. In the start() method in Adventure.java (i.e. the file thatalso contains your main method)
i. obtain a reference to the controller object
ii. invokethe controller'sstartGame() method and pass it the reference to the map of the world (i.e. the graph data structure with the World map). The controller's startGame() method is described above.

Phase 4:
There are several commands that can be executed by entering the command in the command text fieldbox in the GUI.
We are again going to use polymorphism and inheritance to perform the commands. The UML diagram for the hierarchy for the command classes is given below. Note that some of the commands have an argument (e.g. the room to go to) and others do not (e.g. search which just searches the current room). The super class Command therefore has two constructors. One which will set argument to null and one which is passed the argument to be associated with the command.

Now when a command is enteredin the command text field your application must:
1. determine if it is a valid command;
2. If it is a valid command, then create an instance of the appropriate command type;
3. If it is not a valid command, then create an instance of the UnknownCommand;
4. Use the command's perform method to perform the command (polymorphically)

Phase 5
In this phase, instead of building the graph to represent the map of the world using the arrays you have copied into the World class, you are to loadthe data from a database. In this phase you must remove (or comment out) the code you used to build the graph using the arrays.
The database will have two tables. One table (ROOMS) will have all the information about a room (it's id and both descriptions). The second table (EDGE) will have the information about all the doors accessible from a room. To simplify this task, every room will have 3 doors.
Just as in phase 2, output the data in the graph data structure that was built using the data in the database. Again display your graph data on the standard output using World's displayMap() method.

Attachment:- Practical Assessment.rar

Reference no: EM132639708

Questions Cloud

How do calculate the total cost of the product : Calculate the total cost of your product. Estimate the cost to manufacture a bottle of water and get it onto a convenience store shelf.
What is the difference between gdp and gnp : What is the difference between GDP and GNP? What are the limitations of GDP as a measurement tool.
What amount of the expenses will qualify for credit : Judy's expenses for her third year at a university include the following: $3,000 for tuition, What amount of the expenses will qualify for Credit
Predicted impact of this inflow of financial capital : In the 2008 global financial crisis, many investors considered the U.S. economy a safe place to move their assets.
Develop and test a software application : Develop and test a software application that employs a Graphical User Interface (GUI) developed using JavaFXand a graph data structure which is configured
Prepare an income statement for external users : Prepare an income statement for external users. Did you need to prepare a supporting statement of cost of goods manufactured? Explain.
Demonstrated those skills and characteristics : Think about times when you have demonstrated those skills and characteristics. What did you do? How well did you do it? What was the result?
What is the amount of Bob excess SST : He paid Social Security taxes of $7,492.70 from his primary job and $1,178.00 from his second job. What is the amount, if any, of Bob's excess SST
International monetary fund and work bank in washington : What was the anti-globalization movement goal- and was it right? Explain you answer.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Problem aa savings account object holds a nonnegative

problem aa savings account object holds a nonnegative balance and provides depositk and withdrawk methods where

  Company facilitate access to its customers

Recently, the FBI asked Apple Computer to help unlock an iPhone. To what degree should a company facilitate access to its customers' encrypted data?

  Write java program prints strings given at command line

Write down the program Average.java which just prints strings which it is given at command line, one per line. If nothing is given at command line, print "No arguments".

  What is the order of execution of operators

What errors does this class have? How would you fix them? Rewrite the correct version of this class - Explain what each of the two program segments computes

  Experimental evaluation subjects and design

SE4367 Software Testing, Verification, Validation and Quality Assurance Assignment help and solution, The University of Texas at Dallas, Assessment help.

  Write a java application using netbeans ide

Modify the Java application using NetBeans IDE to meet these additional and changed business requirements:

  Cascading style sheet to a website

Compare and contrast the process of adding JavaScript and a Cascading Style Sheet to a Website. Determine if they can be used simultaneously in a page.

  Java nearest neighbor algorithm

I need a java class named "Topology" that includes methods "NearestNeighbor" and "RandomNeighbor".

  Implementation of small to medium sized application programs

Implement basic event-driven programming and graphical user interfaces in Java - implementation of small to medium sized application programs

  What is the purpose of using javascript on a website what

what is the purpose of using javascript on a website? what is a specific example of a javascript application that will

  Java program which, given three sides of a triangle

Produce a Java program which, given three sides of a triangle, determines whether the triangle is:

  Demonstrate instances of each class and tests

Demonstrate instances of each class and tests of all control paths in a program.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd