∨ The programming task — Find your dogs!
You have two Yorkshire Terriers, let’s call them Bistol and Poo (to protect their identities). They’re on the run from Deputy Prime-Minister and HiFi store magnate Jarnaby Boyce, and you’ve got to find them before he does!
You will search the states of Australia for your beloved doggies. When you see them you’ll try to catch them so that they’re safe. To do this you have to lure them towards you. But they’re playful and will only come the third time you call. If, however, you encounter Jarnaby while looking for them: you’re in trouble buddy! You’ll be so hurt by his rebuke that you will be dazed for two moves — run into him again while you’re dazed and go home Yankee, go home! You can call the dogs while dazed but you will stay dazed; you must move twice to clear your head. But dazed or not, you can only erroneously call out to the puppies three times — if you shout in the wrong direction three times, you will be found by Jarnaby and deported. And who will look after the puppies then Captain? Game over. Indeed.
When you are not dazed it is possible for you to have some idea of your location, the states around you, and the location of your dogs (because their continuous annoying yapping gives their location away).
The on-line version of this document has a link to some sample output of both a stage 2 and stage 4 implementation of this game.
The completed implementation will consist of three files, only one of which must be written by you. These files are:
AssigTwo216.java This is the driver program (with a main() method). The code of this is complete and it MUST NOT be changed (unless Stage 4 is reached). The code in this file is very simple — it declares and instantiates an object of thePirateDog class and calls its play() method. (The on-line version of this document has a link to the code.)
R2JCD2.java This is a library class and this file contains resources that you are to use in developing your implementation of the task. The code is complete and MUST NOT be changed. (The on-line version of this document has a link to the code.)
PirateDog.java This is an organiser class and is the file that you are to write; the on-line version of this document has a link to a ‘skeleton’ version of the code — use this as the starting point for your program.
There will be no main() method in the class, it will contain methods that organise the task. This will include all the interactions with the user.
You should make sure that you do the following:
Create and use object(s) of the R2JCD2 class. You will LOSE MARKS if you write code in PirateDog.java that duplicates things that could be done using methods of the R2JCD2 class.
Use the trace() method (provided in the skeleton) to include tracing messages in your program — switch the messages off before submission.
Use separate methods to implement the separate activities within the task.
Use instance variables to store data that is used or changed by more than one method and/or needs to persist for the life of the object.
Use local variables to store the data that is used by just one method.
This program (like all programs) should be developed in stages, with each stage fully implemented and tested before the next stage is attempted. To provide you with some guidance about this, the detailed specification below is divided into four stages, you should aim to submit a program that implements at least stage 1.
A program that correctly implements stage 1 and provides all the required external documentation, both to a high standard will be able to score a maximum of 48 of the 60 marks. This is 80% — a high distinction. If you have done all of this in plenty of time and want to try for an even higher mark, then you should begin to implement stage 2, and if you have time stages 3 and 4. Note that you will receive NO marks for your attempts to implement later stages if the marker finds that your implementation of earlier stages does not function as specified in this document.
VERY IMPORTANT: You must state in the header comments of your source code which stage of implementation your program has reached. If you do not do this then the marker may assume that you have only implemented stage 1 and you may not receive any marks for implementation of any other stages.
Details – Stage 1
(Note: even within stage 1, you should plan, implement, and test your program in sub-stages. It is part of your task to work these sub-stages out yourself.)
Write code in PirateDog.java to do the following:
“Housekeeping” tasks — PirateDog()
Instantiate the R2JCD2 and Scanner classes.
Switch on the debugging/tracing messages in the PirateDog and R2JCD2 classes. (Switch them off before you submit your program for assessment.)
Introduction — explain()
Provide the user with a general explanation of the game.
Play the game — the user is prompted to make “moves” until the game is over.
The game will end when any one of the following happens:
You try to move to the state occupied by Jarnaby while you are dazed.
You call the dogs when they’re not there three times.
You call the dogs successfully three times.
You choose to quit the game.
Before each move you are provided with information. If you are dazed then you are only reminded that you need to find the dogs, otherwise you are told:
Your current location in Australia.
The numbers of the four connecting states.
The number of times you have called the dogs both successfully and unsuccessfully.
Any available information about the location of the dogs — i.e. whether you can hear their barking.
Any available information about the location of Jarnaby — i.e. whether music from JB’s HiFi can be heard.
You will be asked what you want to do for this turn. The options are:
Fly into another state (by number).
You will be asked to enter the number of the state you want to fly into.
If the state is not connected to your current location you will not be able to fly, and should be told so.
Otherwise if the state is connected to you current location, you will enter the new state and
if the new state doesn’t contain the dogs or Jarnaby the game will continue (with you becoming slightly less dazed if you were dazed)
if the new state does contain Jarnaby and you were already dazed then the game is over, otherwise you become dazed and Jarnaby leaves to give a press conference.
if the new state does contain the dogs then they will run away.
Call into another state (by number).
You will be asked to enter the number of the state you want to shout into.
If the state is not connected to your current location, you will be told this.
If the state is connected and contains the dogs then it is noted that they have been called and the game continues. When this occurs for the third time, the dogs come to you and the game ends, otherwise the dogs run away.
If the state is connected but doesn’t contain the dogs then it is noted that you’ve drawn attention to yourself unnecessarily and the game continues. When this occurs three times, the Australian Federal Police will arrest you and deport you and the game ends.
Reset the Game.
If this option is chosen then many game parameters are reset:
your position is changed.
the dogs’ position is changed.
Jarnaby’s position is changed.
your head is cleared (i.e. you are not dazed)
the shouting tallies are reset to 0.
Quit the game.
The game will end.
Details – Stage 2
Remember
You should only consider implementing this if you have completed and tested stage 1 and have time to spare.
You must state in the header comments of your source code that you have implemented stage 2.
Extra functionality at this stage:
Before playing, you are asked whether or not you want to play, if not, there is no game played.
After each game is over, you are asked whether you want to play again.
The numbers of the states that the user enters should also be remembered (to a maximum of 20 moves and then the most recent 20 should be remembered). These values (in chronological order) should be displayed at the end of the game. Seesample output for more information.
Details – Stage 3
Remember
You should only consider implementing this if you have completed and tested stage 2 and have time to spare. There is a lot of extra work in this Stage for very few marks.
You must state in the header comments of your source code that you have implemented stage 3.
Extra functionality at this stage
Design and build a graphical user interface (GUI) for the output of the program (display of messages after each move, and the final messages). The input (including prompts to the user) will be from the console (using methods of the Scanner class) (as in stages 1 and 2).
NOTE: You are not expected to, and should not attempt to write your own code to open, position, arrange, or close the GUI.
Write extra code in PirateDog.java (which should now extend QuickGUI)
“Housekeeping” tasks — PirateDog()
Create the GUI (consisting of Fly, Call, Reset, and Quit buttons, and (perhaps) a read-only text field and two ordinary text fields).
Show the information to the player and present them with their choices — paintComponent()
Add the functionality of displaying the user’s status on the GUI within a new method: paintComponent().
Place calls to repaint() within the program.
You may find some Tutorials helpful.
Details – Stage 4
Remember
You should only consider implementing this if you have completed and tested stage 3 and have time to spare. There is a huge amount of extra work in this Stage for very few marks.
You must state in the header comments of your source code that you have implemented stage 4.
Extra functionality at this stage
Make the graphical user interface interactive, that is all interaction between the user and the program should be through the GUI.
NOTE: You are not expected to, and should not attempt to write your own code to open, position, arrange, or close the GUI.
Write code in PirateDog.java (which should now also implement ActionListener) to do the following:
“Housekeeping” tasks — PirateDog()
Ensure ActionEvents will be listened for by the buttons and a text field.
Comment out the call to play() in the AssigTwo216.java file.
Manage the pressing of buttons and typing in the text field — actionPerformed()
If the user has elected to fly, shout, reset, or quit
Manage this appropriately (similar to the play() method).
repaint() the screen.
You may find some Tutorials helpful.
â–· Planning and Documentation
∨ Program Style
The code you write for this assignment must be a single class called PirateDog, with the code in a file called PirateDog.java. This class should not have a main() method, execution of the code will be initiated from the “driver” program AssigTwo216.java(supplied). It is expected that the code in PirateDog.java will instantiate an R2JCD2 object (code supplied) and will call its methods.
Your program should follow the coding conventions introduced in this unit, especially:
Variable identifiers should start with a lower case letter
final variable identifiers should be written all in upper case and declared before non-final variables
All local variables (with the exception of loop counters in for loops) should be declared at the start of methods and before any other Java statements
Every if-else statement should have a block of code for both the if part and the else part (if used)
Every loop should have a block of code
The program should use final variables as much as possible
Opening and closing braces of a block should be aligned
All code within a block should be aligned and indented 1 tab stop from the braces marking this block
Commenting:
There should be a block of header comment which includes at least
file name, student name and ID, stage of development reached
Each variable declaration should be commented
There should be header comments for each method indicating:
What the method does
The purpose of the parameters (if there are any)
What the return value (if any) is for
∨ Help and hints:
Read the specification carefully and make sure that you know what your program needs to do. Work out some pencil and paper examples.
Break the problem down into subtasks. For each of these tasks
Produce an algorithm before writing any code.
When you start to code add only a small amount of code at a time.
Compile and run to check that this part is working before proceeding.
Test thoroughly to see that the program you have written performs this task correctly.
You will waste a lot of your time if you do not follow a step-by-step method of solving a problem such as this. It is a mistake to think that this step-by-step method is slower than trying to tackle the whole problem at once. It never is.
Once you think you have completed your program, test it thoroughly to ensure it works correctly. Repeat these tests if you make any modifications to your program.
DO NOT neglect your tutorial work in the unit to work on the assignment. Some of the tutorial activities may lead you to see what needs to be done in the assignment.
You may seek help with this assignment in normal consultation times for this unit or via email to your lecturer. Here are some hints to make best use of help.
Make sure you know (or think you know) what your problem is.
Have details of the work you have done so far and the progress you have made on hand when you seek help.
The more specific you can be in your request for help the more immediately useful the help is likely to be.
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount! Use Discount Code “Newclient” for a 15% Discount!NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.
The post Java programming programming homework help appeared first on Nursing Writers Hub.


0 comments