next up previous
Next: About this document ...

Assignment #2
CpSc 481: Object Technology with C++
Computer Science Department
Clemson University
Brian Malloy
Classes, Lists, Iterators, overloaded operators and Memory Management
Extended Precision Arithmetic
February 16, 2005

In order to receive credit for this assignment, it must be submitted, using the handin command, by 9 AM on Monday, March 7th.

The purpose of this assignment is to provide an opportunity for you to become familiar with C++ classes, nested classes, iterators, overloaded operators, pointer variables and memory management, and efficiency considerations. In order to receive full credit, your program must compute 1#1 in less than 2 seconds.

Your program should include a C++ class that encapsulates the concept of a large unsigned number; I'll refer to this class as BigInt, but you can call it anything you like, such as ExtendedInt, LargeInt, ExtendedInteger, etc.

For this assignment you may not use any container functionality in the standard C++ library - you must write your own list class, together with forward and reverse iterators that operate on your list class.

This assignment will help you understand pointer variables and how memory is managed; in particular, you will not be able to compute 1#1 in two seconds if you have a memory leak. Also, you will see how iterators work in the standard C++ library. Finally, an important aspect of this assignment is for you to get some practice in assigning responsibilities to classes, in OO fashion. Thus, your list class should only be responsible for list functionality, not addition, or other arithmetic operations. Arithmetic operations should be assigned to your BigInt class as overloaded operators. Most importantly, all of your classes should be in canonical form.

To help you get started, we will write some of the list functions that you will need, and we will also write some of the iterator class. Also, I will provide an example of a GUI program that uses SDL to retrieve textual input from the user and, as the user is typing, will print the leet translation. You can also use both my solution and any other student's solution to the first assignment as a basis for solving this second assignment. These solutions can be found on my web page and the GUI input example can be found at:

http://www.cs.clemson.edu/~malloy/courses/481-2005/assign/2/newleet/

To get full credit, you will need to write code to accomplish the following:

  1. Implement a general list class. This class does not have to be templated, but lists are perfect candidates for templates: you will learn a lot by using templates, and you will be more likely to reuse your list class for future courses and work if it uses templates.
  2. Implement both a forward and reverse iterator. Both iterators must be nested in your list class
  3. Implement any other functionality needed by your BigInt class, including overloaded operators for addition, multiplication, etc.
  4. Use SDL to get input from the user and to print your answer to a screen. To facilitate parsing the infix expression, you can assume that there are blanks on each side of the operator and that the expression is not preceded by blanks. Also, you can assume that the input is a valid infix expression with two positive operands of arbitrary precision and one operator for addition, multiplication or exponentiation.
  5. Your answer for 1#1 should be nicely formatted on the GUI canvas.

You are not required, nor is it expected, that you implement all of the functionality in the STL list.

Your GUI must be implemented with SDL. Your program and your GUI should handle arithmetic expressions of the form:

<operand> <operator> <operand>
Where 2#2operand3#3 is a positive integer of arbitrary precision, and 2#2operator3#3 is either 4#4, 5#5, or 6#6. Thus, legal expressions include:
2 * 999999999999999999999999999999999999
33333333333333333333333333333333333 * 444444444444444444444
2 ^ 1000

Your GUI can be modeled after the extended leet example that I will demo in class and have placed on the web page; or, you can write your own GUI. However, your GUI should look good, be easy to use and provide hints to help the user demo your program. I will caution you that some of the pitfalls of using SDL for our GUI is that it may be somewhat difficult to retrieve an operator, such as 4#4, since there are two keystrokes involved. Figure [*] illustrates output from the instructors solution.

Figure: Sample output. This figure illustrates a GUI constructed with SDL. The user has typed an infix expression in the top window and the result is illustrated in the bottom window.
Image example

In your submitted program, include all files that we need to run your program, including the ttf file. Please do a make clean before you submit. Also, include a README file for your submitted solution that describes you, the course and the assignment. Please list the strengths and weaknesses of your solution, what it does and does not do.

Finally, use the handin command to submit you final program. The handin command works as follows:

handin.481.2 <asgn #> <files>
for example:
handin.481.2 2 *




next up previous
Next: About this document ...
Brian Malloy 2005-02-16