![]() |
![]() |
|
home—info—lects—labs—exams—hws
tutor/PIs—breeze (snow day)
Object120 + its docs—java.lang docs—java.util docs
We will continue working on Tuesday's lab about objects-containing-objects.
int a = 93
int b = 17;
// Now, we try to swap the contents of these two local variables:
a = b;
b = a;
// What do things look like?
|
/** Swap this Hideout's president and a crewmember.
* @param crewIndex The index of which crewmember to make president.
* It must be an integer in [0,this.crew.length).
*/
void elect( /* Hideout this, */ int crewIndex ) { /* stub */ }
|
/** Swap this Hideout's president and the most popular crewmember.
*/
void holdElection() { ... }
|
(You should complete at least this far.)
Hint: A handy helper method would take anyRobot r and anyRobot[] crowd , and determine whetherr would pick a fight with any member ofcrowd .
Once this is written, how can you use it to determine whether each crewmember might combat any other member of the crew?
home—info—lects—labs—exams—hws
tutor/PIs—breeze (snow day)
Object120 + its docs—java.lang docs—java.util docs
| ©2012, Ian Barland, Radford University Last modified 2012.Nov.29 (Thu) |
Please mail any suggestions (incl. typos, broken links) to ibarland |
![]() |