联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2022-05-22 02:00

KXO151 Programming & Problem Solving AIEN-SHOU - 2022


Assignment 3


The Programming Task

Beware - the version that you implement must match the specifications given below and use the resources provided (even if you prefer some other variant of the task). Other implementations will score poorly.

The code you are to write is to complete an implementation of the game "Hunt the Wumpus". This game was one of the earliest text-based computer games, versions have been available from at least the mid 1970s.

In this game the user is in a system of interconnected dark caves hunting the wumpus. Each cave is connected to three other caves.

If the user enters the cave containing the wumpus they will be eaten, the aim is to kill the wumpus before this happens. The user is armed with a bow and 3 arrows, if they shoot into the cave containing the wumpus it will be killed. To make the task a little more challenging, one cave contains a bottomless pit, if the user enters this cave they will fall into the pit and be killed.

It is possible for the user to have some idea of the location of the wumpus because its unpleasant personal habits mean that it can be smelt from a connecting cave.

It is possible for the user to have some idea of the location of the pit because it causes a breeze that can be felt from a connecting cave.


The completed implementation will consist of 3 files, only one of which must be written by you. These files (available from the unit MyLO site) are:

?Asst3.java - This is the driver program (with a main() method). The code of this is complete and it MUST NOT be changed. The code in this file is very simple - it declares and instantiates an object of the WumpusGame class.

?WumpusBot.java - 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.

?WumpusGame.java - This is the file that you are to write.

oThere 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.

oYou should make sure that you do the following:

?Create and use object(s) of the WumpusBot class. You will LOSE MARKS if you write code in WumpusGame.java that duplicates things that could be done using methods of the WumpusBot 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.

?Use local variables to store the data that is used by just one method.


Details on writing code in WumpusGame.java

Write code in WumpusGame.java to do the following:

?"Housekeeping" tasks -- WumpusGame()

oInstantiate the WumpusBot and Scanner classes.

oSwitch on the debugging/tracing messages in WumpusBot objects and the WumpusGame classes. (Switch them off before you submit your program for assessment.)

oCall play().

?Introduction - Provide the user with a general description of the game.

?Play the game -- the user is prompted to make "moves" until the game is over.

oThe game will end when any one of the following happens:

?The user kills the wumpus (user wins).

?The user is eaten by the wumpus (user loses).

?The user falls into the pit (user loses).

?The user chooses to quit the game (user loses).

oBefore each move the user is provided with the following information:

?Their location (cave number) in the cave system.

?The numbers of the three connecting caves.

?The number of arrows they have.

?Any available information about the location of the wumpus or the pit: If the wumpus is in a connecting cave there will be a horrible smell. If the pit is in a connecting cave there will be a chilling breeze.

oThe user is asked what they want to do for this move. The options are:


?Walk into another cave. They will be asked to enter the number of the cave they want to walk into.

?If this is not connected to their current location they will not be able to walk, they will be told that they now have a nasty bruise on their shoulder from bumping into the wall.

?If this is connected to their current cave, they will enter the new cave (that is, their location will change to the chosen cave); if this is the cave with the wumpus, they will be eaten; if this is the cave with the pit, they will fall in; if this cave is empty, this cave will be their new location and the game will continue, they will be provided with information and prompted for their next move.

?Shoot into another cave.

?If they have any arrows left, they will be asked to enter the number of the cave they want to shoot into, otherwise they will told that they cannot shoot and be prompted for their next move.

?If the cave they choose to shoot into is not connected to their current location, the arrow will bounce off the wall and be lost.

?If the cave they choose to shoot into is connected to their current location and is the cave that contains the wumpus, it will be killed; if it is connected but does not contain the wumpus the arrow will be lost in the empty cave, the user will be prompted for their next move.

?Quit the game. The game will end.

A sample output of the assignment is attached to the end of this document. Use it as a guide to develop your version of the game.


Planning

The first thing that you need to do is to understand what uses can be made of objects of the

WumpusBot class. To do this:

?Read the code carefully, making sure that you can identify

oinstance variables

omethods - read the header comments and the code of these and work out what they do.

?Write a driver program to instantiate an object of the WumpusBot class and call its methods (to check that they behave the way that you think they do).

?Plan how to write code to "organise" the game (using object(s) of the WumpusBot class)

oWork out the subtasks that will be needed (each of these should be implemented as a method).

oWork out the data that will need to be "shared" by more than one method. These will usually be implemented with instance variables.

oFor each method work out:

?the data it will need to have passed in (parameters)

?the data it will need to pass out (return value)

?the algorithm for doing the subtask

?Implement each step after you have planned it - a little bit at a time - compile and test the implementation as you go.


Documentation

Your program files should be fully documented, at least to the same standard as demonstrated in the textbook. This includes in-code comments, descriptions, and where appropriate, explanations for each new constructor, method and variable. Documentation also includes the layout of the Java code and the data printed out to the screen, which should both be in a clear and professional format.


Important Notes:

PLEASE NOTE: This assignment is to be completed by students in groups of 2. If you need help, please look at the textbook or ask your lecturer. Students who have been working through the tutorial exercises should have no difficulty in completing this assignment.


PLEASE NOTE: The submitted Java code must be able to be compiled from the command line using Javac the Java programming language compiler command, or from a basic editor such as jGrasp. Be aware that development programs such as Eclipse often use features only available when run using their system, meaning that their code may not run on a system without their development program. Programs that do not run from the command line using javac (to compile) and java (to run) because of a missing development program feature will fail the assignment.


?Changing a few variable names, adding different data and / or adding your name to the top of someone else’s code does not make it your own work. See the section on ‘Plagiarism’ below.

?Before you submit your assignment through the KXO151 MyLO website, it is suggested that you make sure the final version of your Java program file compiles and runs as expected – do not change the names of the java file – submit it exactly as you last compiled and ran it. PROGRAMS THAT DO NOT COMPILE AND / OR RUN WILL FAIL THE ASSIGNMENT. If in doubt, you can click on the submitted files, download them from MyLO, and check that they are the files you think they should be.

?Only one complete submission is required from each group.

?It is up to the members of the group to make sure their assignment files have been submitted correctly.


Program Style

Your program should follow the coding conventions introduced in this unit and shown in the textbook, especially:

?Variable identifiers should start with a lower case letter

?Final variable identifiers should be written all in upper case and should be declared before all other variables

?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 (if used)

?The program should use final variables as much as possible

?The keyword continue should not be used

?The keyword break should only be used as part of a switch statement (if required)

?Opening and closing braces of a block should be aligned

?All code within a block should be aligned and indented 1 tab stop (approximately 4 spaces) from the braces marking this block


Commenting:

?There should be a block of header comment which includes at least

?file name

?your name (in pinyin)

?student UTas id number

?a statement of the purpose of the program

?Each variable declaration should be commented.

?There should be a comment identifying groups of statements that do various parts of the task.

?There should not be a comment stating what every (or nearly every) line of the code does - as in:

num1 = num1 + 1; // add 1 to num1



Guide to Assessment and Expectations:


The assessment of Assignment 3 is based on the following criteria:

CriteriaHigh DistinctionDistinctionCreditPassFail

Provided a completeProvided a completeProvided a completeProvided a completeFailed to provide a

working set of Javaworking set of Javaworking set of Javaworking set of Javacomplete working set

classes that fullyclasses that satisfy theclasses that satisfy theclasses that satisfyof Java classes that

satisfy therequirements statedmajor requirementsmost of the major thesatisfy the

Working Java Classes / Programrequirements stated in the assignment requirements,

including easy to usein the assignment requirements, including easy to use

interface, usingstated in the assignment requirements,

including a relativelyrequirements stated in the assignment requirements,

including a usablerequirements stated in the assignment requirements & / or

fail to compile & / or

interface, usingArrays, and correcteasy to use interface,interfacerun

Arrays, and correctuse of namesusing at least 1 Array,

use of namesand correct use of

names

Provided completeProvided reasonablyProvided goodProvided someFailed to provide

documentation of allcompletedocumentation ofdocumentation ofdocumentation of

significant & relevantdocumentation ofsignificant & relevantsignificant & relevantsignificant & relevant

Documentationaspects of the Java classes.significant & relevant aspects of the Javaaspects of the Java classes.aspects of the Java classes.aspects of the Java classes, & / or failed

Submission of correctclasses.Submission of correctSubmission of correctto submit coversheet

& correctly namedSubmission of correctfiles & coversheetfiles & coversheet

files, & coversheetfiles & coversheet

DemonstratedDemonstrated veryDemonstrated goodDemonstrated basicFailure to

excellent clear andgood design skills –design skills - showsdesign skills – showsdemonstrate

logical design skills –shows evidence ofevidence of beingsome evidence ofadequate

shows considerablebeing planned in alogically designed andbeing a logicallyunderstanding of the

Overall Program

Designevidence of planning

at a very professional level. Design is logical,logically way.

Program is a very good solution to thea good solution to the

programming problem. Is andesigned solution to

the programming problem, and most ofnature of Java.

Little or no evidence of any planned design

(Understanding of Java)and is a complete solution to theprogramming problem, and is aadequately tested solutionthe methods return the correct values– little or no form or structure.

programmingthoroughly tested

problem. Showssolution

evidence of thorough

testing of the solution


NoteThe High Distinction grade is reserved for solutions that fully meet the requirements & are highly distinguished from other assignments by their high quality work, their attention to detail, & by demonstrating a high-level an understanding and ability to program using the Java language (usually only 10% of students).


相关文章

版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp