| CIS 330 Home Page | Last updated 2008/02/27 11:33:57 |
The problems in this assignment are optional. You can do any or all of the problems for extra credit toward your assignment score total. Each problem is worth 40 points.
Use the driver code complexTest.c to test your implementation and determine the behavior you must implement. Note that this driver does various tests of operations, but your solution should have complete sets of operators. That is, the driver may only use ==, but you should define both == and !=. Likewise, the driver may only use a few arithmetic operators, but you should define addition, subtraction, multiplication, and division, and the compound assignment forms of these as well. Define the interface to your class in a file named Complex.h and the implementation in a file named Complex.c.
Running this program should produce the following:
b is 1.2 + 2.35i c is 2.3 + 5.45i e is 2.3 + 5.45i d is -8.4 + 6.82i f is -8.4 + 6.82i Now d is 1.23591 + 0.163016i Now f is -1.23591 + -0.163016i a is 2.3 + 5.45i c is 3.3 + 5.45i a and c are different b is 5 + 0i 5 and b are the same
The driver code queueTest.c defines a Customer object that derives from QueueNode and simulates a set of checkout lanes with customers randomly assigned to a lane and checked out. The amount of time taken by a customer is effectively random, but each queue maintains the order of the customers on a first in, first out basis.
Use the driver code to test your implementation of Queue and QueueNode. Define the interface to both your classes in a single file named Queue.h and the implementation in a file named Queue.c.
Running this program with values 3 and 10 could produce the following:
Customer1 (entered at 2) checked out at 6 Customer5 (entered at 9) checked out at 10 Customer2 (entered at 4) checked out at 12 Customer4 (entered at 8) checked out at 17 Customer3 (entered at 5) checked out at 25 Customer7 (entered at 13) checked out at 28 Customer8 (entered at 14) checked out at 31 Customer9 (entered at 15) checked out at 38 Customer6 (entered at 11) checked out at 42 Customer10 (entered at 16) checked out at 43
The driver code stackTest.c shows how your Stack class must work. Put your code all in a single header file Stack.h.
This driver produces the following results:
Stack contains: [21 19 17 15 13 11 9 7 5 3] 21 19 17 15 13 11 9 7 5 3 Stack contains: [] Stack contains: [14 13 12 11 10 9 8 7 6 5 4 3 2 1 0] Stack contains: [7 6 5 4 3 2 1 0] Curly Moe Harry Dick Tom