-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path_ArithmeticOperations.gen.m
More file actions
111 lines (82 loc) · 2.72 KB
/
_ArithmeticOperations.gen.m
File metadata and controls
111 lines (82 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
%% ¡header!
ArithmeticOperations < ConcreteElement (ao, arithmetic operation calculator) calculates simple arithmetic operations.
%%% ¡description!
An Arithmetic Operation Calculator (ArithmeticOperations) contains two
numbers as data scalar props and calculates their sum and difference as
result scalar props.
%%% ¡seealso!
LogicalOperations, GeometricalOperations
%% ¡props_update!
%%% ¡prop!
ELCLASS (constant, string) is the class of the arithmetic operation calculator.
%%%% ¡default!
'ArithmeticOperations'
%%% ¡prop!
NAME (constant, string) is the name of the arithmetic operation calculator.
%%%% ¡default!
'Arithmetic Operation Calculator'
%%% ¡prop!
DESCRIPTION (constant, string) is the description of the arithmetic operation calculator.
%%%% ¡default!
'An Arithmetic Operations element (ArithmeticOperations) contains two numbers as data scalar props and calculates their sum and difference as result scalar props.'
%%% ¡prop!
TEMPLATE (parameter, item) is the template of the arithmetic operation calculator.
%%%% ¡settings!
'ArithmeticOperations'
%%% ¡prop!
ID (data, string) is a few-letter code for the arithmetic operation calculator.
%%%% ¡default!
'ArithmeticOperations ID'
%%% ¡prop!
LABEL (metadata, string) is an extended label of the arithmetic operation calculator.
%%%% ¡default!
'ArithmeticOperations label'
%%% ¡prop!
NOTES (metadata, string) are some specific notes about the arithmetic operation calculator.
%%%% ¡default!
'ArithmeticOperations notes'
%%% ¡prop!
TOSTRING (query, string) returns a string that represents the object.
%%%% ¡calcualte!
a = ao.get('A');
b = ao.get('B');
value = ['Calculator of the sum and difference of ' num2str(A) ' and ' num2str(B)];
%% ¡props!
%%% ¡prop!
A (data, scalar) is the first number.
%%% ¡prop!
B (data, scalar) is the second number.
%%% ¡prop!
SUM (result, scalar) is the sum of the two numbers (A + B).
%%%% ¡calculate!
value = ao.get('A') + ao.get('B');
%%% ¡prop!
DIFF (result, scalar) is the difference of the two numbers (A - B).
%%%% ¡calculate!
value = ao.get('A') - ao.get('B');
%% ¡tests!
%%% ¡test!
%%%% ¡name!
Simple test
%%%% ¡code!
ao = ArithmeticOperations('A', 6, 'B', 4)
string = ao.get('TOSTRING')
assert(~ao.isLocked('A'))
assert(~ao.isLocked('B'))
sum = ao.get('SUM')
assert(ao.isLocked('A'))
assert(ao.isLocked('B'))
diff = ao.get('DIFF')
sum_raw = ao.getr('SUM')
diff_raw = ao.getr('DIFF')
assert(isa(sum_raw, 'NoValue') && isa(diff_raw, 'NoValue'))
%%% ¡test!
%%%% ¡name!
Simple test with memorization
%%%% ¡code!
ao = ArithmeticOperations('A', 6, 'B', 4)
sum = ao.memorize('SUM')
diff = ao.memorize('DIFF')
sum_raw = ao.getr('SUM')
diff_raw = ao.getr('DIFF')
assert(~isa(sum_raw, 'NoValue') && ~isa(diff_raw, 'NoValue'))