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:
parent
8ed2c77fec
commit
dff4c99126
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user