OO Programming with Java


Algebra, Signals and Datasets

The objective here is to manipulate mathematical entities in an object-oriented manner. For instances, numbers, vectors, matrixes, images, sets, etc. have all values and operators. This fact can be formalized by the following interface:

WARNING: use Numeric<X> in plus/mult !

Questions.

  1. Encode the preceding model.
  2. As a first application, Numbers can be represented by a class implementing the preceding interface and having an integer value as attribute (see figure below). Thus, implements numbers and show how to compute the expression "1+(2*3)".
  1. As a second application, Signals, or vectors, can be represented by a class implementing the Numeric interface and having a list of integers as attribute (see figure below). Thus, implements Signal objects and show how to compute the expression "[1,2]+([2,2]*[3,4])".
  1. As a variation of the preceding exemple and a third application, it is possible to define Sets with plus meaning union, and mult meaning intersection. Thus, implements Sets objects and show how to compute the expression "{1,2}+({3,4}*{4,5})".
  1. The preceding example can be generalized by adding a type variable (see figure). Thus adapt the preceding implementation and show how to compute the expression {"A","B"}+({"C","D"}*{"D","E"}).