Class CostPerformanceDatabase

java.lang.Object
com.zybooks.dsaj.map.CostPerformanceDatabase

public class CostPerformanceDatabase extends Object
Maintains a database of maximal (cost,performance) pairs.
  • Constructor Details

    • CostPerformanceDatabase

      public CostPerformanceDatabase()
      Constructs an initially empty database.
  • Method Details

    • best

      public Entry<Integer,Integer> best(int c)
      Returns the (cost,performance) entry with largest cost not exceeding c. (or null if no entry exist with cost c or less).
      Parameters:
      c - an upper limit on the desired cost
    • add

      public void add(int c, int p)
      Add a new entry with given cost c and performance p.
      Parameters:
      c - the cost of the new entry
      p - the performance of the new entry
    • toString

      public String toString()
      Returns a string representation of the entry (for debugging use).
      Overrides:
      toString in class Object
      Returns:
      a string representation of the entry (for debugging use)
    • main

      public static void main(String[] args)