CSE 303: Autumn 2006, Assignment 5

Due: Wednesday 15 November 2006, 2:00pm

Updates

Assignment Overview

This is an individual assignment in which you will write some simple C++ programs, create a C++ class, and debug C++ programs. Begin by downloading hw5.tgz and unpacking it with tar -xvzf hw5.tgz. This contains all the files referred to in this assignment.

1. Vectors, Strings, and Streams

Write the following programs in C++. Whenever possible, you must avoid the use of C style arrays, strings, and output in favor of the vector template, the string class, and cout. You do not need to define any classes to write these programs.

2. Point Class

The file Point.h defines a Point class that will be used in the forthcoming assignments and is a pattern for other classes we will make. The file Problem2Main.cpp makes use of this class. Your task is to create the file Point.cpp that implements the Point class. If you compile your class with the following command...

g++ -g -Wall -o Problem2 Problem2Main.cpp Point.cpp

... then running the command "./Problem 2" should produce the following output...

Distance between points 1 and 2 is 4.47214
Points 0 and 3 are Equal
(0,0)
(1,2)
(-1,-2)
(0,0)
(3,4)

You may implement this class in any way you wish, as long as it meets the specification in Point.h and produces correct output. The following is a description of the 11 methods or functions that you must implement.

Advice

The sample solution to Point.cpp is 70 lines long, including 25 lines that are either blank or contain nothing but comments. In fact, 25 lines in the sample solution are nearly equivalent to lines in Point.h, and it is very reasonable to start working by copying Point.h into Point.cpp and working from there.

3. Debugging C++ Programs

The following four C++ programs, included with your assignment, are all supposed to have the same behavior. All programs should produce no errors or warnings when compiled on attu with "g++ -Wall". All should run on attu, producing no output and returning with error code 5. Each has a flaw, however, that prevents it from doing this. You must identify the flaw and describe it in readme.txt (under the heading "Problem 3" and a sub-heading which is the name of the program). You must also fix the program and turn it in.

4. Extra Credit

Remember the course policy on extra credit. You may do either or both of the following problems.

Assessment

Your solutions should be

Turn-in instructions

Use the standard turn-in instructions described here. For problem 1, you should turn in repeated.cpp and matrixcheck.cpp. For Problem 2, you should turn in Point.cpp. For Problem 3, you should make entries in readme.txt and turn in bug1.cpp, bug2.cpp, bug3.cpp, and bug4.cpp.If you do this first extra credit problem, you should turn in bugec.cpp. If you do the second, you should turn in ECMain.cpp, Pointec.h, and Pointec.cpp.