@Test(expectedExceptions = {UnsupportedOperationException.class}) public void testNonViableDivCauseType2() { BtrpSet s = new BtrpSet(1, BtrpOperand.Type.NUMBER); s.div(new BtrpNumber(3.2)); }
@Override public BtrpSet div(BtrpOperand nb) { if (nb instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) nb; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int s = x.getIntValue(); if (s == 0) { throw new UnsupportedOperationException("Illegal division by 0"); } if (s > size()) { throw new UnsupportedOperationException("Divider can not be greater than the set cardinality"); } int card = (int) Math.ceil(size() * 1.0 / s); BtrpSet res = new BtrpSet(degree() + 1, t); BtrpSet cur = new BtrpSet(degree(), t); res.add(cur); for (int i = 0; i < size(); i++) { cur.add(values.get(i)); if (cur.size() == card && i != size() - 1) { cur = new BtrpSet(degree(), t); res.add(cur); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); }
BtrpSet extends DefaultBtrpOperand { @Override public BtrpSet div(BtrpOperand nb) { if (nb instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) nb; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int s = x.getIntValue(); if (s == 0) { throw new UnsupportedOperationException("Illegal division by 0"); } if (s > size()) { throw new UnsupportedOperationException("Divider can not be greater than the set cardinality"); } int card = (int) Math.ceil(size() * 1.0 / s); BtrpSet res = new BtrpSet(degree() + 1, t); BtrpSet cur = new BtrpSet(degree(), t); res.add(cur); for (int i = 0; i < size(); i++) { cur.add(values.get(i)); if (cur.size() == card && i != size() - 1) { cur = new BtrpSet(degree(), t); res.add(cur); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); } }
BtrpSet extends DefaultBtrpOperand { @Override public BtrpSet div(BtrpOperand nb) { if (nb instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) nb; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int s = x.getIntValue(); if (s == 0) { throw new UnsupportedOperationException("Illegal division by 0"); } if (s > size()) { throw new UnsupportedOperationException("Divider can not be greater than the set cardinality"); } int card = (int) Math.ceil(size() * 1.0 / s); BtrpSet res = new BtrpSet(degree() + 1, t); BtrpSet cur = new BtrpSet(degree(), t); res.add(cur); for (int i = 0; i < size(); i++) { cur.add(values.get(i)); if (cur.size() == card && i != size() - 1) { cur = new BtrpSet(degree(), t); res.add(cur); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); } BtrpSet(int d, Type ty); }
BtrpSet extends DefaultBtrpOperand { @Override public BtrpSet div(BtrpOperand nb) { if (nb instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) nb; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int s = x.getIntValue(); if (s == 0) { throw new UnsupportedOperationException("Illegal division by 0"); } if (s > size()) { throw new UnsupportedOperationException("Divider can not be greater than the set cardinality"); } int card = (int) Math.ceil(size() * 1.0 / s); BtrpSet res = new BtrpSet(degree() + 1, t); BtrpSet cur = new BtrpSet(degree(), t); res.add(cur); for (int i = 0; i < size(); i++) { cur.add(values.get(i)); if (cur.size() == card && i != size() - 1) { cur = new BtrpSet(degree(), t); res.add(cur); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); } BtrpSet(int d, Type ty); @Override Type type(); @Override BtrpSet plus(BtrpOperand s); @Override BtrpSet minus(BtrpOperand s); int size(); @Override int degree(); @Override BtrpSet remainder(BtrpOperand other); @Override BtrpSet div(BtrpOperand nb); @Override BtrpSet times(BtrpOperand s); @Override BtrpSet power(BtrpOperand nb); @Override String toString(); @Override BtrpSet copy(); @Override boolean equals(Object o); @Override BtrpNumber eq(BtrpOperand other); @Override int hashCode(); List<BtrpOperand> getValues(); }
BtrpSet extends DefaultBtrpOperand { @Override public BtrpSet div(BtrpOperand nb) { if (nb instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) nb; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int s = x.getIntValue(); if (s == 0) { throw new UnsupportedOperationException("Illegal division by 0"); } if (s > size()) { throw new UnsupportedOperationException("Divider can not be greater than the set cardinality"); } int card = (int) Math.ceil(size() * 1.0 / s); BtrpSet res = new BtrpSet(degree() + 1, t); BtrpSet cur = new BtrpSet(degree(), t); res.add(cur); for (int i = 0; i < size(); i++) { cur.add(values.get(i)); if (cur.size() == card && i != size() - 1) { cur = new BtrpSet(degree(), t); res.add(cur); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); } BtrpSet(int d, Type ty); @Override Type type(); @Override BtrpSet plus(BtrpOperand s); @Override BtrpSet minus(BtrpOperand s); int size(); @Override int degree(); @Override BtrpSet remainder(BtrpOperand other); @Override BtrpSet div(BtrpOperand nb); @Override BtrpSet times(BtrpOperand s); @Override BtrpSet power(BtrpOperand nb); @Override String toString(); @Override BtrpSet copy(); @Override boolean equals(Object o); @Override BtrpNumber eq(BtrpOperand other); @Override int hashCode(); List<BtrpOperand> getValues();  }