|
home—info—lects—labs—exams—hws
tutor/PIs—Object120 + its docs—java.lang docs—java.util docs
We continue our exploration of objects from the previous lecture (and lab).
Review:
Where do you put fields, in the class-file?;
what is different about a constructor --
what name to use when calling constructor?;
when writing the signature, three differences from normal signatures?
We access fields using the
For example:
If we have a variable
The general syntax is:
field-access ::= exprobject.namefield |
We'll see later, how the
starting code for lecture; finished code from lecture.
starting code for lecture; finished code from lecture.
starting code for lecture; finished code from lecture.
/** Which of two robots is cooler? * @param bot1 The first Robot. * @param bot2 The second Robot. * @return Either bot1 or bot2, depening on who is cooler. * A robot with a *shorter* transformed-shape description is cooler; * in case of ties, the evil one is cooler. */ |
starting code for lecture; finished code from lecture.
/** Make a new, evil copy of a given Robot. * @param aBot The Robot to make an evil copy of. * @return a new, evil copy of `aBot`. * (Evil copies have the original's serial number but * with a '-E' concatenated; they are always evil; * they have the same disguise and transformation status. */ |
(See the links above.)
1
Hopefully we get the question, after making test cases:
What to do in case of a tie?
Note that Java forces us to return a
home—info—lects—labs—exams—hws
tutor/PIs—Object120 + its docs—java.lang docs—java.util docs
©2010, Ian Barland, Radford University Last modified 2010.Oct.07 (Thu) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |