CombinedTable free response problem from the 2021 AP Computer Science A Exam

CombinedTable is #2 from the from the 2021 AP Computer Science A Free Response problems.

https://apcentral.collegeboard.org/pdf/ap21-frq-computer-science-a.pdf?course=ap-computer-science-a

CombinedTable class

public class CombinedTable
{
    private SingleTable t1, t2;

    public CombinedTable(SingleTable t1, SingleTable t2)
    {
        this.t1 = t1;
        this.t2 = t2;
    }
        
    public boolean canSeat(int people)
    {
        int seats = t1.getNumSeats() + t2.getNumSeats() - 2;
        return seats <= people;
    }
        
    public double getDesirability()
    {
        double averageView = (t1.getViewQuality() + t2.getViewQuality()) / 2;

        if(t1.getHeight() == t2.getHeight())
            return averageView;
        else
            return averageView - 10;
    }
}

See Class writing order for a technique to respond to AP CS FR that request an entire class.

2021 AP CS Exam Free Response Solutions

Additional classes & objects resources

Comments

Comment on CombinedTable