From 6919fac18f074d7faf7d9eca107442cefb6a9ce2 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 24 Jul 2017 14:37:56 -0700 Subject: [PATCH] Add promotion implementation. --- src/org/nwapw/abacus/number/NaiveNumber.java | 5 +++++ src/org/nwapw/abacus/number/Number.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/org/nwapw/abacus/number/NaiveNumber.java b/src/org/nwapw/abacus/number/NaiveNumber.java index 0ac9418..484f773 100644 --- a/src/org/nwapw/abacus/number/NaiveNumber.java +++ b/src/org/nwapw/abacus/number/NaiveNumber.java @@ -48,5 +48,10 @@ public class NaiveNumber implements Number { return new NaiveNumber(1); } + @Override + public Number promoteTo(Class toClass) { + if(toClass == this.getClass()) return this; + return null; + } } diff --git a/src/org/nwapw/abacus/number/Number.java b/src/org/nwapw/abacus/number/Number.java index c2e7540..4541287 100755 --- a/src/org/nwapw/abacus/number/Number.java +++ b/src/org/nwapw/abacus/number/Number.java @@ -12,4 +12,6 @@ public interface Number { Number zero(); Number one(); + Number promoteTo(Class toClass); + }