CS/SWE 332 In Class Exercise Number 14
October 16, 2017

Name(s):
Topics: Inheritance, invariants, dispatching, abstract states
public class IntSet {
    public void insert(int x) {...; repOk();}
    public void remove(int x) {...; repOk();}
    public boolean repOk() {...}
}
public class MaxIntSet extends IntSet {
    private int biggest;  // the biggest element if the set is not empty

    public void insert(int x) {...; super.insert(x); repOk();}
    public void remove(int x) {super.remove(x); ...; repOk();}
    public boolean repOk() {super.repOk(); ...;}
    public int max() {  // return max value }
}
   MaxIntSet s = {3, 5}; s.remove(5); 
There are two logical choices for an abstract state for MaxIntSet. What are they, which one should you prefer, and why?

Would your answer change for a SortedIntSet class?

Analyze the repOk() calls.