-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathswisscalc.display.memoryDisplay.js
57 lines (48 loc) · 1.37 KB
/
swisscalc.display.memoryDisplay.js
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
//
// Eric Morgan
// Copyright (c) 2014.
//
// Class for displaying/storing the memory on a calculator.
var swisscalc = swisscalc || {};
swisscalc.display = swisscalc.display || {};
swisscalc.display.memoryDisplay = function() {
this._display = "";
this._memValue = 0;
this._hasMemory = false;
};
// Returns true if memory is set.
swisscalc.display.memoryDisplay.prototype.hasMemory = function() {
return this._hasMemory;
};
// Returns current display
swisscalc.display.memoryDisplay.prototype.getCurrentDisplay = function() {
return this._display;
};
// Returns memory value.
swisscalc.display.memoryDisplay.prototype.memoryRecall = function() {
return this._memValue;
};
// Sets the memory to the given value.
swisscalc.display.memoryDisplay.prototype.memorySet = function(val) {
this._hasMemory = true;
this._memValue = val;
this._display = "M";
};
// Adds given number to the memory.
swisscalc.display.memoryDisplay.prototype.memoryPlus = function(val) {
this._hasMemory = true;
this._memValue += val;
this._display = "M";
};
// Subtracts the given value from memory.
swisscalc.display.memoryDisplay.prototype.memoryMinus = function(val) {
this._hasMemory = true;
this._memValue -= val;
this._display = "M";
};
// Clears the memory.
swisscalc.display.memoryDisplay.prototype.memoryClear = function() {
this._hasMemory = false;
this._memValue = 0;
this._display = "";
};