Width { public Width add(final Width that) { final int min = this.min + that.min; final int max = this.max + that.max; return new Width(min, max); } Width(final int min, final int max); Width toMin(); Width toMax(); static Width ofString(final String string); Width adjust(final Width that); Width add(final Width that); Width subtract(final Width that); int getMin(); int getMax(); @Override String toString(); static final Width ZERO; }
@Test public void add() { final Width a = new Width(3, 10); final Width b = new Width(7, 11); final Width c = a.add(b); assertEquals(10, c.getMin()); assertEquals(21, c.getMax()); }