Commit 29aa04cd by Patryk Czarnik

podklasa do kalkulatora

parent 7bbae22b
...@@ -8,4 +8,6 @@ public interface KalkulatorWielometodowy { ...@@ -8,4 +8,6 @@ public interface KalkulatorWielometodowy {
int mul(int x, int y); int mul(int x, int y);
int div(int x, int y); int div(int x, int y);
int mod(int x, int y);
} }
package kalkulatory;
public class KalkulatorWielometodowyBepieczny extends KalkulatorWielometodowyImpl {
private static final int TYSIAC = 1000;
@Override
public int add(int x, int y) {
return Math.addExact(x, y);
}
@Override
public int sub(int x, int y) {
return Math.subtractExact(x, y);
}
@Override
public int mul(int x, int y) {
return Math.multiplyExact(x, y);
}
}
...@@ -21,4 +21,9 @@ public class KalkulatorWielometodowyImpl implements KalkulatorWielometodowy { ...@@ -21,4 +21,9 @@ public class KalkulatorWielometodowyImpl implements KalkulatorWielometodowy {
public int div(int x, int y) { public int div(int x, int y) {
return x / y; return x / y;
} }
@Override
public int mod(int x, int y) {
return x % y;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment