Your program must consist of two classes (as described below). Aside from the
'main()' method you are not to write static methods
for this assignment. (If you don't know what I'm referring to by static methods,
I will be discussing this topic later in the course). If you do implement other static methods
then you will receive few, if any, marks for features listed below. Also to make
it easier to mark ensure that your method carries out the prescribed tasks
exactly as specified (so the the person knows precisely what results should come
out at what times).
- Defines a class 'Adventurer' (6 marks)
|
|
-
Attributes: name
(String), and
health
(int) (2 marks)
|
|
|
|
|
|
- A no argument constructor that sets the
name and health attributes
to obvious default starting values (e.g., "nameless"
for the name and -1 for the health (2 marks)
- A 'gainLevel()' method that
displays a message onscreen ("Congratulations!")
and increases health by 5. (2 marks)
|
|
|
|
- Defines the 'Driver' class. The 'main()'
method will contain the following instructions (8 marks)
|
|
- Declares a reference to an 'Adventurer' (1 mark)
- Creates an 'Adventurer'
object by calling the default constructor (1 mark)
- Displays the health and name of the adventurer, the default
values should appear (2 marks)
- Uses the mutator methods to set the name
to 'Balin' and health to 10 (2 marks)
- Calls the 'gainLevel()' method of
the adventurer (1 mark)
- Displays the health and name of the adventurer, the new values
should appear 'Balin' and
15 (1 mark)
|