Professional Documents
Culture Documents
IOO Semester 1 2021 Assignment Part 2
IOO Semester 1 2021 Assignment Part 2
IOO Semester 1 2021 Assignment Part 2
La Trobe University
Due Date
Due : Friday 21st of May 2021 at 10.00 a.m.
Delays caused by computer downtime cannot be accepted as a valid reason for a late submission without
penalty. Students must plan their work to allow for both scheduled and unscheduled downtime.
Copying, Plagiarism
Plagiarism is the submission of somebody else’s work in a manner that gives the impression that the work
is your own. The Department of Computer Science and Information Technology treats academic
misconduct seriously. When it is detected, penalties are strictly imposed. Refer to the subject guide for
further information and strategies you can use to avoid a charge of academic misconduct. All submissions
will be electronically checked for plagiarism.
You may be asked to give an interview through zoom and explain your code, if found suspicious
by the plagiarism checker on the submission server. Failing to demonstrate proper understanding
of your program may result in zero marks awarded for the assignment.
Assessment Objectives
To learn from feedback
To practise using Interfaces
To practise using Recursion
To practise using Linked Lists
Marking summary
This assignment is worth 30% of your final mark in this subject.
Implementation 50%, execution of code 50%
Marking Scheme
Provided on LMS in a separate document.
All of the Tasks that follow can be solved using techniques that have been presented in lectures, lecture /
workshops and labs so far.
These are the techniques and knowledge that we will later be examining in the exam (60 marks).
Code and techniques that are outside the material presented will not be examined, of course.
For demonstrating the knowledge taught in this subject, you can only use the standard classes (and
subclasses of such) below and user defined classes.
eg.
File to submit:
After submitting the files, you can run the following command that lists the files submitted from your
account:
verify
You can submit the same filename as many times as you like before the assignment deadline; the
previously submitted copy will be replaced by the latest one.
Please make sure that you have read page 1 about the submission close off date
Background - Task
This program will extend assignment 1. This program introduces monsters. The hero can fight a single
monster or can fight a list of monsters. The program will be menu driven.The menu includes the options:
1. Create Hero, 2. Display Hero, 3. Heal Hero, 4. Single Battle, 5. Battle From List, 6. Save Hero to File,
7. Load Hero From File.
You can only add public static methods or private methods to the classes given. (Including
those from Assignment 1) (except instructed methods)
You can only add private final attributes to the classes given (Including those from
Assignment 1). (except instructed attributes)
You cannot change the signature of methods if given. (Including those from Assignment 1)
You are very welcome and encouraged to design the user interface however you like as long as it conforms to
the marking criteria of assignment 1 and 2, and is clear, usable and contains the same features.
You are very welcome and encouraged to design the user prompts however you like.
Including extra information in the battle is fine. Eg. Health bar.
If you want to add a feature and are not sure if it will interfere with the marking, just ask.
Make a new directory for assignment 2 and copy assignment 1 solution into this folder.
Rename the Adventure.java file to Adventure2.java, make the necessary changes inside the file to reflect
the new class name Adventure2
Create two methods in the Adventure2 class, and leave the body empty for now
Add a method void addPotions(Inventory otherInventory) that calls addPotions from the inventory
attribute and passes otherInventory into the method
The program should compile at this point, and the hero should be able to be saved and loaded! Double
check!
Damageable – has one abstract method named takeDamage that returns a boolean and accepts an int
Fightable – has one abstract method named attack that returns an int
BattleReady - that extends both Damageable and Fightable, and has two abstract methods, getHealth that
returns an int and getName that returns a String
attack – all Heros use the same attack method, it should return:
Math.Random multiplied by 100 multiplied by level and the result cast to an int
getName – this should return 'Archer' if the Hero is an Archer, 'Mage' if the Hero is a Mage or 'Warrior' if
the Hero is a Warrior. Think carefully about how you implement this (Should this be an abstract method or
not in Hero class?)
It has three attributes, name, health and level, with types String, int and int respectively.
The name and level should be able to be passed to the constructor. The health should be set as
100*level when constructed
The signature for the method MUST be as follows (0 marks for this section if it is not)
This method MUST use recursion (0 marks for this section if it is not)
The fight continues until one fighter faints (both should not faint!)
If figher1 faints false is returned, else if fighter2 faints then true is returned.
You are welcome to use either Indirect or Direct recursion. (For indirect create two more methods and call
from this method)
There should be no more than 2 'fights' in the method if using direct, and no more than 1 in each method
if using indirect.
Write the singleBattle method, such that if no hero exists the user is informed.
The monsters name and level is read from the user(range of level between 1-20,
use readInt created in assignment1)
The function should exit after 5 invalid entries. (You do not have to validate the name, just the level)
Instantiate the monster using values entered.
If the hero losses the battle, hero is set to null, and the user is informed they will need a new hero
Else the reward expierence is given to the hero (use gain experience) and is shown on screen (show also
if they levelled up) (You do not have to show the bonus expierence)
And the reward potions is given to the hero (use addPotions) and shown on screen
You may want to use keyboard.nextLine() to make the user press enter between turns
Create a MonsterNode class, that stores a Monster, and the next MonsterNode
(You should not have name, health or level attributes in the MonsterNode class!)
Example Executions:
This examples are only examples and do not show all execution, you should test on many different test cases
The execution test is done on latcs8 so please make sure that your code runs on latcs8 before you
submit.