Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

abstract RingElement

  • Loading branch information...
commit 8a58f8099e634831aecaef65ebb9226e608fd8cf 1 parent 8dacc97
@fibo authored
View
9 lib/Collection.js
@@ -1,6 +1,8 @@
var Element = require('./Element.js');
+var InvalidArgumentsException = require('./Exception/InvalidArguments.js');
+
function Collection() {
var self = this;
@@ -10,7 +12,14 @@ function Collection() {
// ... vabbè, per ora è solo un' idea, cmq si può implementare.
var _elements = arguments[0];
+ var _dimension = 1;
+ var _orders = [0];
+
function getElements() { return _elements; };
+
+ function getElementByIndices(indices) {
+
+ };
};
module.exports = Collection;
View
2  lib/Exception/InvalidArguments.js
@@ -1,5 +1,6 @@
function InvalidArguments() {
+ var self = this;
// TODO message attribute, and inherit from Generic Exception
// TODO emit error
@@ -8,4 +9,5 @@ function InvalidArguments() {
};
+module.exports = InvalidArguments;
View
4 lib/Exception/UnimplementedAbstractMethod.js
@@ -1,5 +1,7 @@
function UnimplementedAbstractMethod() {
-
+ var self = this;
};
+module.exports = UnimplementedAbstractMethod;
+
View
5 lib/Real/Element.js
@@ -3,6 +3,8 @@ var util = require('util');
var RingElement = require('../RingElement.js');
+var InvalidArgumentsException = require('../Exception/InvalidArguments.js');
+
function RealElement() {
var self = this;
@@ -14,6 +16,9 @@ function RealElement() {
if (typeof arguments[0] == 'number') {
_num = arguments[0];
}
+ else {
+ new InvalidArgumentsException();
+ }
self.num = function () { return _num; };
View
22 lib/RingElement.js
@@ -3,6 +3,8 @@ var util = require('util');
var Element = require('./Element.js');
+var UnimplementedAbstractMethodException = require('./Exception/UnimplementedAbstractMethod.js');
+
function RingElement() {
var self = this;
@@ -11,5 +13,25 @@ function RingElement() {
util.inherits(RingElement, Element);
+function abstractMethod() {
+ new UnimplementedAbstractMethodException();
+};
+
+RingElement.prototype.negation = abstractMethod;
+
+RingElement.prototype.addition = abstractMethod;
+
+RingElement.prototype.subtraction = abstractMethod;
+
+RingElement.prototype.inversion = abstractMethod;
+
+RingElement.prototype.leftMultiplication = abstractMethod;
+
+RingElement.prototype.rightMultiplication = abstractMethod;
+
+RingElement.prototype.leftDivision = abstractMethod;
+
+RingElement.prototype.rightDivision = abstractMethod;
+
module.exports = RingElement;
View
1  test/Element.js
@@ -21,4 +21,3 @@ describe('Element', function () {
});
});
-
View
31 test/RingElement.js
@@ -9,7 +9,8 @@ var element = new RingElement();
describe('RingElement', function () {
describe('constructor:', function () {
- it('', function () {
+ it('works', function () {
+ assert.ok(element instanceof RingElement);
});
});
@@ -19,22 +20,42 @@ describe('RingElement', function () {
});
});
- describe('lmul()', function () {
+ describe('negation()', function () {
it('is an abstract function', function () {
});
});
- describe('rmul()', function () {
+ describe('addition()', function () {
it('is an abstract function', function () {
});
});
- describe('rinv()', function () {
+ describe('subtraction()', function () {
it('is an abstract function', function () {
});
});
- describe('linv()', function () {
+ describe('leftMultiplication()', function () {
+ it('is an abstract function', function () {
+ });
+ });
+
+ describe('rightMultiplication()', function () {
+ it('is an abstract function', function () {
+ });
+ });
+
+ describe('inversion()', function () {
+ it('is an abstract function', function () {
+ });
+ });
+
+ describe('leftDivision()', function () {
+ it('is an abstract function', function () {
+ });
+ });
+
+ describe('rightDivision()', function () {
it('is an abstract function', function () {
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.