Class Tree
java.lang.Object
|
+--Tree
- All Implemented Interfaces:
- java.lang.Comparable
- public class Tree
- extends java.lang.Object
- implements java.lang.Comparable
Class Tree
This class define the Tree objects used within
the 15-111/200 Mastery Exam/Fall 2002
Students are not permitted to modify or augment
this class in any way. This file must not change.
You are not required to understand the implementation
of these methods. But, it will likely be useful
for you to understand what they can accomplish
for you.
Exam for 15-111/200 Fall 2002
Constructor Summary |
Tree(int heightInFeet,
double priceInDollarsAndCents,
int qualityFrom1Through10)
This is the constructor of a Tree. |
Method Summary |
int |
compareTo(java.lang.Object anotherTree)
This compares two trees based on their heightInFeet |
int |
getHeightInFeet()
This is returns the recorded hieght of the Tree in whole feet |
double |
getPriceInDollarsAndCents()
This is returns the selling price of the Tree |
int |
getQualityFrom1Through10()
This is returns the quality of the Tree |
java.lang.String |
toString()
Returns a String representation of a Tree including all fields |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Tree
public Tree(int heightInFeet,
double priceInDollarsAndCents,
int qualityFrom1Through10)
- This is the constructor of a Tree.
getHeightInFeet
public int getHeightInFeet()
- This is returns the recorded hieght of the Tree in whole feet
- Returns:
- the height of the Tree in whole feet.
getPriceInDollarsAndCents
public double getPriceInDollarsAndCents()
- This is returns the selling price of the Tree
- Returns:
- the selling price of the tree in dollars, with cents as
a fraction
getQualityFrom1Through10
public int getQualityFrom1Through10()
- This is returns the quality of the Tree
- Returns:
- the quality of the tree from 1-10, where 10 is best.
a fraction
compareTo
public int compareTo(java.lang.Object anotherTree)
- This compares two trees based on their heightInFeet
- Specified by:
compareTo
in interface java.lang.Comparable
- Returns:
- 0 if =, -1 if anotherTree is greater, 1, otherwise
value to the buyer
toString
public java.lang.String toString()
- Returns a String representation of a Tree including all fields
- Overrides:
toString
in class java.lang.Object
- Returns:
- a String containing a representation of the Tree