This question involves a class CombinedTable representing two SingleTable objects pushed together. A person can sit at a combined table if there is room for them at one of the single tables.
SingleTable Class (provided)
public class SingleTable
{
/** Returns the number of seats */
public int getNumSeats()
{ /* implementation not shown */ }
/** Returns the height in inches */
public int getHeight()
{ /* implementation not shown */ }
/**
* Returns the quality of the view from this table:
* 1 = bad, 2 = okay, 3 = good
*/
public int getViewQuality()
{ /* implementation not shown */ }
/** Sets the number of seats */
public void setNumSeats(int num)
{ /* implementation not shown */ }
}
When two tables are combined:
- Total seats = sum of seats minus 2 (lose 2 seats at the joining point)
- Tables can only be combined if they have the same height
- The desirability is the average of the view qualities
CombinedTable Requirements
public class CombinedTable
{
// Constructor: takes two SingleTable objects
// canSeat(int n): returns true if n people can sit
// getDesirability(): returns average view quality
}