interface.sol 861 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. interface operator {
  2. function op1(int32 a, int32 b) external returns (int32);
  3. function op2(int32 a, int32 b) external returns (int32);
  4. }
  5. contract ferqu {
  6. operator op;
  7. constructor(bool do_adds) {
  8. if (do_adds) {
  9. op = new m1();
  10. } else {
  11. op = new m2();
  12. }
  13. }
  14. function x(int32 b) public returns (int32) {
  15. return op.op1(102, b);
  16. }
  17. }
  18. contract m1 is operator {
  19. function op1(int32 a, int32 b) public override returns (int32) {
  20. return a + b;
  21. }
  22. function op2(int32 a, int32 b) public override returns (int32) {
  23. return a - b;
  24. }
  25. }
  26. contract m2 is operator {
  27. function op1(int32 a, int32 b) public override returns (int32) {
  28. return a * b;
  29. }
  30. function op2(int32 a, int32 b) public override returns (int32) {
  31. return a / b;
  32. }
  33. }