ldevillez

Expression

Nov 18th, 2016
458
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Constant\4
  2.     attr a1
  3.     meth init(X) a1:= X end
  4.     meth evaluate($) @a1 end
  5. end
  6. class Variable\4
  7.     attr a1
  8.     meth init(X) a1:= X end
  9.     meth set(X) a1:=X end
  10.     meth evaluate($) @a1 end
  11. end
  12. class Addition\4
  13.     attr a1 a2
  14.     meth init(X Y) a1:=X a2:=Y end
  15.     meth evaluate($)
  16.       {@a1 evaluate($)} + {@a2 evaluate($)}
  17.     end
  18.  
  19. end
  20. class Subtraction\4
  21.     attr a1 a2
  22.     meth init(X Y) a1:=X a2:=Y end
  23.     meth evaluate($)
  24.       {@a1 evaluate($)} - {@a2 evaluate($)}
  25.     end
  26. end
  27. class Multiplication\4
  28.     attr a1 a2
  29.     meth init(X Y) a1:=X a2:=Y end
  30.     meth evaluate($)
  31.        {@a1 evaluate($)} * {@a2 evaluate($)}
  32.     end
  33. end
  34. class Division\4
  35.     attr a1 a2
  36.     meth init(X Y) a1:=X a2:=Y end
  37.     meth evaluate($)
  38.         {@a1 evaluate($)} div {@a2 evaluate($)}
  39.     end
  40. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×