Computer Science 3675
Summer 2000
Programming Assignment 6

Due: June 12

Procedural and functional programming both encourage you to organize programs so that similar functions working on different kinds of data are grouped together. For example, when you write the derivative function, all of the different kinds of derivative formulas are put into a single function that computes all different kinds of derivatives. A single simplification function has to deal with any kind of expression, and all simplifications are grouped together.

Object-oriented programming encourages you to organize your program so that different operations that work on the same kind of data are grouped together. For example, all functions (such as computing the derivative and simplification) that work on expressions that are sums are put in one place, and those that work on products are put someplace else. This organization tends to result in software that is more flexible and easier to work with.

The assignment

For this assignment, rework your derivative program into a more object-oriented form. Build a separate file for each kind of expression. All of the operations on a given kind of expression should be put together.

Get files Expression.ast, VarExpr.ast, ConstExpr.ast and SumExpr.ast, implementing the concepts of Expression (a general expression), a variable, a constant and a sum, respectively. Look at them as examples of how to write your new files. Also get TestDeriv.ast, which contains some tests of these. All are in directory /export/stu/3675/deriv. They are also available here.

  • Expression.ast
  • VarExpr.ast
  • ConstExpr.ast
  • SumExpr.ast
  • TestDeriv.ast
  • Add new files to cover difference, products and constant powers, as in the previous assignment.

    You should not have to modify files VarExpr.ast, ConstExpr.ast, SumExpr.ast or Expression.ast at all in order to write your new files. Just add new files. The tester will need to be modified, to make it do more tests.

    Turning in your assignment

    Turn in the assignment as usual by email. Attach only the new files that you have added, not the ones that you got. Also attach your modified tester.