Skip to content

Classes Team Teach HW #11

@eshaank1

Description

@eshaank1

2021 FRQ:

public class CombinedTable {

    private SingleTable table1;
    private SingleTable table2;

    public CombinedTable(SingleTable table1, SingleTable table2) {
        this.table1 = table1;
        this.table2 = table2;
    }

    public boolean canSeat(int numPeople) {
        return numPeople <= (table1.getNumSeats() + table2.getNumSeats() - 2);
    }

    public double getDesirability() {
        double viewQuality1 = table1.getViewQuality();
        double viewQuality2 = table2.getViewQuality();

        if (table1.getHeight() == table2.getHeight()) {
            return (viewQuality1 + viewQuality2) / 2;
        } else {
            return (viewQuality1 + viewQuality2) / 2 - 10;
        }
    }
}

Takes two SingleTable objects as arguments and stores them in the table1 and table2 instance variables.
Calculates the total seating capacity of the combined table as the sum of the seating capacities of the individual tables minus 2.
Retreiveds from table

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions