Class Tree

java.lang.Object
  |
  +--Tree

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 overall value to the buyer
 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
 int getValue()
          This calculate the "value" of the Tree to the buyer.
 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
 

Constructor Detail

Tree

public Tree(int heightInFeet,
            double priceInDollarsAndCents,
            int qualityFrom1Through10)
This is the constructor of a Tree.
Method Detail

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

getValue

public int getValue()
This calculate the "value" of the Tree to the buyer. The higher the "value" the better the buy. It is defined to be the 100*height*quality/price, truncated to an int value
Returns:
the value to the buyer, where larger numbers are better buys

compareTo

public int compareTo(java.lang.Object anotherTree)
This compares two trees based on their overall value to the buyer
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