![]() |
|
#1
|
|||
|
|||
Help....Given
JAVA Code:
Complete this method for the TreeList class: /* InsertAtIndex: Adds nTree to the collection at the specified index position. It does this, by checking to see if there is enough room in the collection, and resizing if necessary. Moving the Tree element that is currently at the specified index position after sliding all the trees currently in the collection to the next index position in the age. Make sure the size() method of this class returns the correct number of trees in the collection after the insertion. */ public void insertAtIndex(Tree aTree, int index) { Complete this method for the TreeList class: /* treesOfSameAge: returns a new TreeList of all Trees whose age is equal to the age of parameter other. */ public TreeList treesOfSameAge(Tree other) { Write the following header and method for the Tree class: compareTo(Tree other) – takes one Tree parameter. If the species of this tree and the other tree are the same, returns a value less than 0 if the height of this tree is less than the height of the other by more than 12 inches, returns a value greater than 0 if the height of this tree is greater than the height of the other by more than 12 inches, returns 0 if the heights of the two trees are within 12 inches of each other. If the species of the two trees are different, than this method returns a value less than 0 if the species of this tree comes before the species of the other tree alphabetically, or else returns a value greater than 0 if the species of this tree comes after the species of the other tree alphabetically. increaseAge(int numYears, double rateOfGrowthPerYear) – increases the age of this tree by the number of years, and the height of this tree by the rate of growth for this tree, per year. told a girl i could help her with her java hw but its far more advanced than what i Know... can anyone help me out here please? it would be greatly apprreciated Last edited by LuciWiz : 30-Apr-2008 at 11:55.
Reason: Please insert your Java code between [java] & [/java] tags
|
|
#2
|
|||
|
|||
Re: Help....for the increaseSize method, just
add the newYears or whatever to the age variable of the class. and for the rateOfChange, just do this JAVA Code:
for the Compare, all this means is that when you type something like: JAVA Code:
it will run all the tests provided in the instructions and return a certain value depending on which it finds. so.... JAVA Code:
Hope this gets you in the right direction... Justin Fox |
|
#3
|
|||
|
|||
Re: Help....Hey Justin im still confused on the compare To method I understand what you wrote before that. thank you!
|
|
#4
|
|||
|
|||
Re: Help....No problem
for the compareTo() method, if you look at the previous post in the line of code: JAVA Code:
And then look at the actual structure of the compareTo method: JAVA Code:
I hope this clarifies everything about the compareTo method. Justin Fox |
Recent GIDBlog
Toyota - 2008 July Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The