- Defines a class 'Adventurer' (Worth
2.0 GPA)
|
|
-
Defines two private attributes: 'health'
(type
int) and 'name'
(type
String) (Worth
0.4 GPA)
|
|
|
|
|
|
- A no argument constructor that sets the
name and health attributes
to the following starting values (e.g., "nameless"
for the name and -1
for the health
(Worth 0.4 GPA)
- A 'gainLevel()' method that
displays a message onscreen ("Congratulations!")
and increases health by 5. (Worth
0.4 GPA)
- An accessor ('get)' method called 'getHealth()'
method that returns the value of the health attribute. (Worth
0.2 GPA)
- An accessor ('get)' method called 'getName()'
method that returns the value of the name attribute. (Worth
0.2 GPA)
- A mutator ('set)' method called 'setHealth()'
method that sets the value of the health attribute to the parameter
passed into it. (Worth 0.2 GPA)
- A mutator ('set)' method called 'setName()'
method that sets the value of the name attribute to the parameter
passed into it. (Worth 0.2 GPA)
|
|
|
|
- Defines class 'Driver'. The 'main()'
method will contain the following instructions (Worth
2.0 GPA
)
|
|
- Declares a reference to an 'Adventurer'.
(Worth 0.3 GPA)
- Creates/instantiates an
Adventurer
object by calling the default constructor.
(Worth 0.3 GPA)
- Displays the health and name of the adventurer
using the two 'get' methods, the default
values should appear.
(Worth 0.4 GPA)
- Uses the mutator methods to set the
name
to 'Balin' and health to 10.
(Worth 0.4 GPA)
- Calls the 'gainLevel()' method of
the adventurer.
(Worth 0.2 GPA)
- Displays the health and
name of the adventurer
again via the get methods, the new values
should appear 'Balin' and
15
(Worth 0.4 GPA)
|