Highlights
Assessment Objectives
• To practise using Inheritance
• To practise using Abstract Classes
• To practise using Exceptions
• To practise using file input and output and directories
Background - Task
This program will implement a user interface for creating a Hero. A Hero is either an Archer, Warrior or Mage. Each has health, a level, experience, max health and an inventory. The Inventory is made up of potions of three different sizes (small, medium and large). When a Hero reaches 1000 experience they
level up and their max health is increased and they are healed. An Archer gains extra experience, a warrior gets more health when levelling up and the Mage has an ability to heal themselves. This program is the base for Assignment 2, in this program the functionality is tested via a menu driven system. The menu includes the options:
1. Create Hero,
2. Display Hero,
3. Heal Hero,
4. Damage Hero,
5. Give Hero Experience,
6. Save Hero to File,
7. Load Hero From File.
Background – Base program
The Adventure class has been partially written for you. This file can be copied from the csilib area:
cp /home/student/csilib/cse1ioo/2021/assign1/Adventure.java .
Some methods have been written for you.
You will need to edit the main method to add your name and your student number.
Copying this again will overwrite the files in the directory. It is your responsibility to ensure this does not happen.
Background – "No information provided"
Where you see "no information provided" you must implement the given method in a professional standard approach based on what you have been taught in OOF and IOO.
Background – Additional Methods, Attributes and Classes
You can only add public static methods or private methods to the classes given.
You can only add private final attributes to the classes given.
You can add other classes if you find it necessary.
Part 1 – Revision, Inheritance and Abstract Classes
1.1 – Create the Class given the below in the UML diagram and method descriptions.
Inventory
int smallPotions
int mediumPotions
int largePotions
Inventory()
Inventory(int smallPotions, int mediumPotions, int largePotions)
int getSmallPotions()
int getMediumPotions()
int getLargePotions()
boolean usePotion(int choice)
String toString()
Inventory() – Should set small potions to 2, medium potions to 1 and large potions to 0
Inventory(int smallPotions, int mediumPotions, int largePotions) – no information provided.
Accessors – no information provided.
toString – no information provided.
usePotion – The choice parameter indicates the type of potion to be used. 1 for small, 2 for medium and 3 for large. If there
is 0 of the potion selected or an invalid value is entered then false should be returned. Else the number of the particular
potion selected should be reduced by 1 and true should be returned.
Eg. If there is 4 small potions, and 1 is passed as choice, then small potions should be reduced by 1 (leaving 3) and true should be returned.
Part 2 – Type Checking and Exceptions
2.1 – Create the Classes as described below.
YNException class
This class should be a subclass of Exception, it should have two constructors, a default constructor, and one that accepts a string.
IntRangeException class
This class should be a subclass of Exception, it should have two constructors,
a default constructor, and one that accepts a string.
ValueChecker class
This should have two static methods:
1. named checkValue that accepts three ints (value, min and max) and returns nothing. It should throw a IntRangeException if the value is not within min and max
2. named checkValue (Overloading) that accepts a single char and returns nothing. It should throw a YNException if the char is not 'Y' or 'N'
2.2 – Create the Methods as described below.
In the Adventure class (this was provided see page 3), you are to create the readInt method. Delete the placeholder text 'To be implemented' in this method and the return.
This CSE1IOO - IT Assignment has been solved by our IT Experts at My Uni Papers. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2025 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.