1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-22 07:20:09 -08:00

Add a way to get a value of a primitive number to the Number interface.

This commit is contained in:
Danila Fedorin 2017-07-24 13:57:14 -07:00
parent 8ed2c77fec
commit dff4c99126
2 changed files with 26 additions and 0 deletions

View File

@ -37,4 +37,24 @@ public class NaiveNumber implements Number {
public Number negate() {
return new NaiveNumber(-value);
}
@Override
public Number zero() {
return new NaiveNumber(0);
}
@Override
public Number one() {
return new NaiveNumber(1);
}
@Override
public Number valueOf(int val) {
return new NaiveNumber(value);
}
@Override
public Number valueOf(double val) {
return new NaiveNumber(value);
}
}

View File

@ -9,4 +9,10 @@ public interface Number {
Number subtract(Number subtrahend);
Number negate();
Number zero();
Number one();
Number valueOf(int val);
Number valueOf(double val);
}