summaryrefslogtreecommitdiff
path: root/assignment-12/cashModel.dcl
diff options
context:
space:
mode:
authorCamil Staps2017-12-11 14:40:48 +0100
committerCamil Staps2017-12-11 14:42:07 +0100
commitf4784a9f4ce7b1a9cb6b0898a191c870f640243f (patch)
tree902e7971f50a63e395439377d51b0ef7a2f318b1 /assignment-12/cashModel.dcl
parentStudent numbers (diff)
Template assignment 12
Diffstat (limited to 'assignment-12/cashModel.dcl')
-rw-r--r--assignment-12/cashModel.dcl26
1 files changed, 26 insertions, 0 deletions
diff --git a/assignment-12/cashModel.dcl b/assignment-12/cashModel.dcl
new file mode 100644
index 0000000..6d1b452
--- /dev/null
+++ b/assignment-12/cashModel.dcl
@@ -0,0 +1,26 @@
+definition module cashModel
+/*
+ Pieter Koopman, Radboud University, 2017
+ pieter@cs.ru.nl
+ Advanced programming
+
+ A simple state model for an automated cash register
+*/
+
+import StdEnv, GenEq
+
+:: Euro = {euro :: Int, cent :: Int}
+:: Product = Pizza | Beer | Cola
+:: Action = Add Product | Rem Product | Pay
+
+class euro a :: a -> Euro
+instance euro Product, Euro
+instance euro Int, (Int, Int), [e] | euro e
+instance + Euro
+instance - Euro
+instance zero Euro
+derive gEq Euro
+instance ~ Euro
+instance == Euro, Product
+
+model :: [Product] Action -> ([Product],[Euro])