## Generating Programs
In the context of an object-oriented programming language such as C++, which has been used to implement EM, an "object" usually refers to an abstraction in the program that incorporates both data structure and behavior. All objects of a given type (class) share the same "behavior" but maintain their own data structure. The data structure of each object is initialized when the object is constructed. Because EM implements the "behavior" for all "known" types of objects, in order to create an exercise we only need to specify what types of objects are involved and provide appropriate information (attributes) needed to initialize their data structures. This is exactly the purpose of the
Any of the objects should be defined as
Forming two separate sublists of and `object-tag` are strings. Of course, `object-type` should be among the "known" types mentioned before. `object-type` will be used by EM as a symbol to which an expression may be assigned. This is explained later in more detail. We distinguish between the `object-tag` of an object and the rest of its `object-value` . The value is an attribute, which is also an expression. It carries the mathematical essence of the object. It is either a double nested list of integers for objects of type `object-attributes` or `Matrix` , or a list of `MatrixEntry` symbols for objects of type `True/False` or `CheckBoxes` . Since we calculate this value by using random numbers, it is different each time the generating program is evaluated. The other attributes, which are only used to determine the visual outlook of the objects in the names of matrices seen by students, labels of check boxes, or radio controls, etc., should be given as strings.
`RadioControls` As an example, consider the generating program of the "Add Two Matrices" exercise (see Figure 2) given in Listing 1. It uses several functions implemented in a package which EM loads at startup. This utility package significantly simplifies the creation of new matrix algebra exercises since various useful functions can be readily used. From this package, function with arguments given in the second list. Similarly, `Random` generates a matrix. `GenMatrix` , `LoMatrixQ` , and `UpMatrixQ` are predicates evaluating to `DiagMatrixQ` if the argument is lower-triangular, upper-triangular, or diagonal matrix, respectively. The program first generates the size of the matrices into `True` . Then two square matrices of size `n` are generated and assigned to `n` and `a` . The sum of `b` and `a` is assigned to `b` . Then we assign to `c` a list to be used as the value of the `rightBx` object. The final step is to construct `CheckBoxes` . There are two object definitions in the problem statement (the left pane in Figure 2), both of type `exerciseList` . The answer template (the right pane in Figure 2) is comprised of one object of type `Matrix` and one of type `MatrixEntry` .`CheckBoxes`
Converted by Mathematica
October 5, 1999
[Prev Page][Next Page] |