Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
28
Task/Classes/MiniZinc/classes.minizinc
Normal file
28
Task/Classes/MiniZinc/classes.minizinc
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
% define a Rectangle "class"
|
||||
var int: Rectangle(var int: width, var int: height) =
|
||||
let {
|
||||
var int: this;
|
||||
constraint Type(this) = Rectangle; %define the "type" of the instance
|
||||
%define some "instance methods"
|
||||
constraint area(this) = width*height;
|
||||
constraint width(this) = width;
|
||||
constraint height(this) = height;
|
||||
} in this;
|
||||
|
||||
%this enum should contain the list of class names
|
||||
enum Type = {Rectangle};
|
||||
function var Type: Type(var int:a);
|
||||
|
||||
%declare the "instance methods"
|
||||
function var int: area(var int:this) = let {var int:result;} in result;
|
||||
function var int: height(var int:a) = let {var int:result;} in result;
|
||||
function var int: width(var int:a) = let {var int:result;} in result;
|
||||
|
||||
%create an instance of the "class"
|
||||
var int: rect = Rectangle(3,4);
|
||||
var int: area1 = area(rect);
|
||||
|
||||
solve satisfy;
|
||||
|
||||
% print the area of the rectangle
|
||||
output [show(area1),"\n"];
|
||||
Loading…
Add table
Add a link
Reference in a new issue