Your program must consist of three 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). Your program must consist
of three classes (as described below). If you do implement other static methods
then you will receive few, if any, marks for features listed below.
- Defines a class 'Cat' (5 marks)
|
|
-
Attributes: name
(String), and favoriteFood
(String) (2 marks)
|
|
|
|
|
|
- A no argument constructor that sets the
name and favoriteFood attributes
to obvious default starting values (e.g., "no
name" for the name and "I hate
everything you give me
>.< " for the food) (2 marks)
- A 'makeSound()' method that
displays "meow" onscreen when the
method is called (1 mark)
|
|
|
|
- Defines a class 'Dog' (4 marks)
|
|
-
Attributes: name
(String) and favoriteFoods
(a String array with two elements) (2 marks)
|
|
|
|
|
|
- A no argument constructor that sets the
name and food attribute to
obvious default starting values (e.g., "no
name" for the name and ["dog food",
"your food"] for the foods) (2 marks)
|
|
|
|
- Defines the 'Driver' class. The 'main()'
method will contain the following instructions (11 marks)
|
|
- Create instances of a dog and cat (2 marks)
- Displays the name and
favorite food attributes of the dog onscreen, the
default values should appear (2 marks)
- Displays the name and
favorite food attributes of the cat onscreen, the
default values should appear (2 marks)
- Sets the name of the cat
to 'Sylvester' and favorite food to 'Catnip' (2 marks)
- Displays the name and
favorite food attributes of the cat onscreen, the
new values should appear (2 marks)
- Calls Sylvester's 'makeSound()' method (1 mark)
|