| CIS 330 Home Page | Last updated 2008/01/17 15:13:58 |
This assignment focuses on using C++ classes to encapsulate data. Several of the problems are object oriented rewrites of the problems in the last assignment, but you should be using only new and delete for any dynamically allocated objects.
Your code should work with the driver intListTest.c, which can also be used to test your implementation. The output should be the same as in problem 1 from the previous assignment.
Use the driver code rationalTest.c to test your implementation and determine the behavior you must implement. Note the different forms of the constructor. Also notice that regardless of the initial values used, the Rational objects are always in lowest terms.
Running this program should produce the following:
r1 is: 4/5 r2 is: 3/1 r3 is: 0/1 r4 is: 3/7 r5 is: 0/1 r1 == r2 is: 0 r2 is: 4/5 r1 == r2 is: 1 r5 = r1 * r4 is: 12/35 r1 + r5 is: 8/7 r4++ is: 3/7 r4 is: 10/7 ++r4 is: 17/7 r4 is: 17/7 r1 * 4 is: 16/5 7 / r4 is: 49/17 r2 - 7 / r4 is: -177/85
Use the following driver code array2dTest.c to test your implementation. Output should be as in Assignment 2.
You can start with this MyString.h and MyString.c.
Use the driver code stringTest.c to test your implementation. This driver produces the following results:
s1 is:<Hello, world>, s1.length() is 12 s2 is:<and goodbye>, s2.length() is 11 s3 is:<Hello, world and goodbye>, s3.length() is 24 Now s1 is:<world>, s1.length() is 5 s2 comes first And now s1 is:<World>, s1.length() is 5 Now s1 comes first Now s3 is:<Hello, world and goodbye >, s3.length() is 25 Now s3 is:<Hello, world and goodbye for now...>, s3.length() is 35