package zahlen;

public class S implements N {
	N n;
		
	public S(N n) {
		super();
		this.n = n;
	}

	@Override
	public N add(N that) {
		return new S(n.add(that));
	}

	@Override
	public N mult(N that) {
		return n.mult(that).add(that);
	}

	@Override
	public int value() {
		return 1+n.value();
	}

	@Override
	public Z add(Z that) {
		if (that instanceof N) {
			N n = (N)that;
			return this.add(n);
		} else {
			return that.add(this);
		}
	}

	@Override
	public Z mult(Z that) {
		if (that instanceof N) {
			N n = (N)that;
			return this.mult(n);
		} else {
			return that.mult(this);
		}	
	}
}

