讲解KXO151留学生、辅导Programming、辅导java程序语言、java编程调试
讲解数据库SQL|辅导Python编程
KXO151 Programming & Problem Solving
AIEN-SOU - 2019
Assignment 3
Due Date & Time: 10pm (Shanghai) Friday, Week 14, 31 May, 2019
Maximum Weight: 30% (of the total assessment for KXO151)
Submission: Via MyLO
NOTE: All assignments will be checked for plagiarism by a specialist Java
program that checks your assignment against other student’s assignments as
well as the Internet (including help sites). For more information see:
www.ics.heacademy.ac.uk/resources/assessment/plagiarism/demo_jplag.html
Assignment Type: Group: 2 students in each group. Students are free to choose who they join
with. A group sign-up sheet is available on the KXO151 MyLO site.
NOTE: Students who have not signed into a group by Friday, 17 May, 2019,
will be assigned into a group without consultation.
NOTE: Each contributing student within the group will receive the same
mark, however, active participation and equal contribution is required from
each member of the group. Students who are found to have not participated
and / or equally contributed to the assignment work will not be included in
the group’s mark. If there is an issue with a student not participating and / or
contributing to your group, please contact your lecturer.
Cover Sheet: The School requires that a group cover sheet listing the members of your
group be submitted with your assignment.
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 a simulation of finding a celebrity (such as a movie
star) and convincing him/her to fall in love with you!
You will search the streets of Los Angeles (of USA) for your favourite celebrity. When you
find them you'll try to convince them to fall in love with you. Obviously, you'll do this by
shouting at them from a distance. If you do so three times, then you will convince them and
you will go off together happily ever after. If, however, you encounter one of their security
guards then you will be dazed for two moves -- run into the security detail while you're
dazed and the game is also over. You can shout 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
your beloved three times -- if you shout in the wrong direction three times, you are
arrested for disturbing the peace and placed in an asylum. Game over.
If you are not dazed then it is possible for you to have some idea of your location, the
streets around you, and the location of your celebrity (because the noise the paparazzi is
making gives their location away).KXO151 - AIEN-SOU – Assignment 3 - 2019
Page 2 of 7
The completed implementation will consist of three (3) files, only one of which must be
written by you. These files 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 CelebStalker class and calls its
play() method.
CelebrityBot.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.
CelebStalker.java - This is an organiser class and is the file that you are to
write. There is a "skeleton" version of the code - use this as the starting point for
your program.
o 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.
o You should make sure that you do the following:
Create and use object(s) of the CelebrityBot class. You will LOSE
MARKS if you write code in CelebStalker.java that duplicates
things that could be done using methods of the CelebrityBot 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 tasks within the
game.
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 CelebStalker.java
Write code in CelebStalker.java to do the following:
"Housekeeping" tasks -- -- CelebStalker()
o Instantiate the CelebrityBot and Scanner classes.
o Switch on the debugging/tracing messages in the CelebStalker and
CelebrityBot classes. (Switch them off before you submit your program
for assessment.)
Introduction -- explain()
o Provide the user with a general explanation of the game.
Play the game -- after entering the gender of their desired celebrity the game is
started with a celebrity chosen at random, the user is prompted to make "moves"
until the game is over.
o The game will end when any one of the following happens:
The user tries to move to the street occupied by the celebrity when
they are dazed.
The user shouts their love to empty streets three times.
The user shouts their love to the celebrity three times.
The user chooses to quit the game.KXO151 - AIEN-SOU – Assignment 3 - 2019
Page 3 of 7
o Before each move the user is provided with information. If they are dazed
then they are only told the name of the celebrity with whom they're in love,
otherwise they are told:
The celebrity's name and the player's current location (street
number) in the Los Angeles road system.
The numbers of the four connecting streets.
The number of times they have declared their love successfully and
unsuccessfully.
Any available information about the location of the celebrity -- i.e.
whether the paparazzi has been detected.
o The user is asked what they want to do for this turn. The options are:
Walk into another street (by number).
The player will be asked to enter the number of the street they
want to walk into.
If the street is not connected to their current location they will
not be able to walk, and should be told so.
Otherwise if the street is connected to their current location,
they will enter the new street and, if the new street doesn't
contain the celebrity the game will continue (with the player
becoming slightly less dazed if they were dazed); if the new
street does contain the celebrity and the player was already
dazed then the game is over, otherwise they become dazed and
the celebrity flees.
Shout into another street (by number).
The player will be asked to enter the number of the street they
want to shout into.
If the street is not connected to their current location, they will
be told this.
If the street is connected and contains the celebrity then it is
noted that they have declared their love and the game
continues. When this occurs three times, the celebrity is
seduced and the game ends.
If the street is connected but doesn't contain the celebrity then
it is noted that they've disturbed the peace and the game
continues. When this occurs three times, the player is arrested
and the game ends.
Reset the Game. If this option is chosen then many game parameters
are reset: a new celebrity (of the same gender) is chosen.
the player's position is changed.
the celebrity's position is altered.
the player's head is cleared (i.e. they are not dazed)
the shouting tallies are reset to 0.
Quit the game. The game will end.
Before playing, the user is asked whether or not they want to play, if not, there is no
game played.
After each game is over, the user is asked whether they want to play again.
The numbers of the streets 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 KXO151 - AIEN-SOU – Assignment 3 - 2019
Page 4 of 7
chronological order) should be displayed at the end of the game. See sample output for
more information.
A sample output of the assignment is enclosed within this assignment information package.
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
CelebrityBot class. To do this:
Read the code carefully, making sure that you can identify
o instance variables
o methods - 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 CelebrityBot 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 "CelebStalker" activity (using object(s) of the
CelebrityBot class)
o Work out the subtasks that will be needed (each of these should be implemented as
a method).
o Work out the data that will need to be "shared" by more than one method. These
will usually be implemented with instance variables.
o For 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.KXO151 - AIEN-SOU – Assignment 3 - 2019
Page 5 of 7
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 num1KXO151 - AIEN-SOU – Assignment 3 - 2019
Page 6 of 7
Guide to Assessment and Expectations:
The assessment of Assignment 3 is based on the following criteria:
Criteria High Distinction Distinction Credit Pass Fail
Working Java
Note
The 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).
Submitting Your Assignment
Only one complete submission is required from each group.
You need to submit your assignment package containing the following 3 files to the unit
MyLO site:
Asst3.java, CelebrityBot.java, CelebStalker.java
Follow these steps to create a package for your assignment files and then submit your package file:
1. Ensure that you add the names and the UTAS ID numbers of both students of your group into the
class header of each of the 3 files, as comments.
2. On your computer desktop, create a new folder using your name and UTAS ID number. For
example, if your name is Jianwen CHEN and your UTAS ID number is 111222, then the new folder
must be named Chen_Jianwen_111222;
3. Copy your 3 assignment files into the new folder;
4. Compress the new folder and name it as a RAR file (or ZIP file). For example, Jianwen CHEN could
name it as Chen_Jianwen_111222.rar.KXO151 - AIEN-SOU – Assignment 3 - 2019
Page 7 of 7
5. Submit your RAR file (or ZIP file) to the unit MyLO site. While submitting, include the names and
UTAS ID numbers of both students as comments.
You must also submit a signed group coversheet to your local lecturer by the assignment due
date. The group coversheet is also on the unit MyLO site, under Assessment.
In submitting your assignment you are agreeing that you have read the “Plagiarism and Academic
Integrity” section below, and that your assignment submission complies with the assignment
requirement that it is your Group’s own work.
Students who believe that this method of submission is unsuitable given their personal
circumstances must make alternative arrangements with their Lecturer prior to the submission
date.
Extensions will only be granted under exceptional conditions, and must be requested with
adequate notice on the Request for Extension forms.
Plagiarism and Academic Integrity
While students are encouraged to discuss the assignments in this unit and to engage in active
learning from each other, it is important that they are also aware of the University’s policy on
plagiarism. Plagiarism is taking and using someone else's thoughts, writings or inventions and
representing them as your own; for example downloading an essay wholly or in part from the
internet, copying another student’s work or using an author’s words or ideas without citing the
source.
It is important that you understand this statement on plagiarism. Should you require clarification
please see your unit coordinator or lecturer. Useful resources on academic integrity, including
what it is and how to maintain it, are also available at: www.academicintegrity.utas.edu.au/.
Acknowledgement
This assignment has been adapted from a programming project developed by Dr Julian Dermoudy. The assignment template
was written by Dr Dean Steer. Both authors are members of School of Technology, Environments and Design, University of
Tasmania, Australia.
(The End)
Plagiarism is a form of cheating. It is taking and using someone else's thoughts, writings or
inventions and representing them as your own; for example, using an author's words
without putting them in quotation marks and citing the source, using an author's ideas
without proper acknowledgment and citation or copying another student’s work.
If you have any doubts about how to refer to the work of others in your assignments, please
consult your lecturer or tutor for relevant referencing guidelines, and the academic integrity
resources on the web at: www.academicintegrity.utas.edu.au/.
The intentional copying of someone else’s work as one’s own is a serious offence punishable
by penalties that may range from a fine or deduction/cancellation of marks and, in the most
serious of cases, to exclusion from a unit, a course or the University. Details of penalties that
can be imposed are available in the Ordinance of Student Discipline – Part 3 Academic
Misconduct, see: www.utas.edu.au/universitycouncil/legislation/
The University reserves the right to submit assignments to plagiarism detection
software, and might then retain a copy of the assignment on its database for the
purpose of future plagiarism checking.