From f4784a9f4ce7b1a9cb6b0898a191c870f640243f Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 11 Dec 2017 14:40:48 +0100 Subject: Template assignment 12 --- assignment-12/cashModel.dcl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 assignment-12/cashModel.dcl (limited to 'assignment-12/cashModel.dcl') 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]) -- cgit v1.2.3