Homework 6 (The Rotating Dead) FAQ
-
Q: What are some good resources or examples I can look at to get started on this program?
-
A: Look at the lecture slides and the
TreeSet
example from Friday's lecture.
If you want to read more about implementing AVL trees, see Chapter 4 of the Weiss textbook.
-
Q: Does my
HvZPlayer
class still need to have an equals
and hashCode
method from HW4?
-
A: The
hashCode
method will probably not be used.
But equals
is still important, and in general, when you override equals
, you should override hashCode
.
You won't be graded on methods outside of compareTo
, but we recommend that you leave in the methods you wrote in HW4.
-
Q: What is a
protected
method?
Why are the methods I need to write in this assignment declared as protected
?
Shouldn't they be public
so that the client can call them?
Should I declare all of my fields as protected
? ...
-
A: A
protected
field can be seen by the class in which it is declared, along with any subclasses and classes in the same package.
The methods in this assignment are protected
because the abstract superclass has already written the public
methods and you don't need to write those.
You are overriding the protected
helper methods that the client is using to recursively implement the adding and removing operations on the tree.
The client will call the abstract class's public
method, which will then call your protected
method as a helper.
In terms of fields, no, you should not declare your fields as protected
on this assignment.
Fields should almost always be private
except in rare cases.
This document and its content are copyright © Marty Stepp, 2013. All rights reserved.
Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form
is prohibited without the author's expressed written permission.