CS 304 Object-Oriented Programming in C++

Spring 2007

Classroom: CH 396, Mondays from 12:00pm-12:50pm


1) Syllabus

 

2) Class Notes

Lecture-1

Lecture-2

Lecture-3

Lecture-4

Lecture-5

Lecture-6

Lecture-7

Lecture-8

Lecture-9

Lecture-10

Lecture-11

Lecture-12

 

 

 

 

 

 

3) Assignments (there will be four assignments this term)

 

 

Assignment #4 (15 points) (Due: Monday, April 30, 2007, before the start of the exam):

 

Q1) ( 8points)

 

Do exercise 13.13. Just use the shape hierarchy in fig. 12.3 (you don’t need to extend it or create a new one).

 

Q2) (7 points) Do exercise 14.6. Use the following class as the user-defined type:

 

// A class for 2D points (x,y)
class Point {
public:
        // Default constructor
        Point(double x = 0.0, double y = 0.0) {
                xval = x;
                yval = y;
        }
 
        // getters
        double x() { return xval; }
        double y() { return yval; }
 
        // Add or subtract two points.
        Point add(Point b)
        {
                return Point(xval + b.xval, yval + b.yval);
        }
        Point sub(Point b)
        {
                return Point(xval - b.xval, yval - b.yval);
        }
 
        // Move the existing point.
        void move(double a, double b)
        {
                xval += a;
                yval += b;
        }
 
        // Print the point on the stream.  The class ostream is a base class
        // for output streams of various types.
        void print(ostream &strm)
        {
                strm << "(" << xval << "," << yval << ")";
        }
 
private:
        double xval, yval;
 
};

 

(For your practice only – you don’t have to hand it in). Try exercise 15.14.

 

 

Assignment #3 (15 points) (Due: Monday, April 9, 2007, before the start of the lecture) :

 

Note: For this assignment, you only need to hand in hard copy solutions.

 

Q1) ( 9 points: 5 + 4)

 

a) Do exercise 12.3.

 

b) Give two original examples (one for inheritance and one for aggregation, using UML class diagrams) where inheritance/aggregation will be more appropriate.

 

Q2) (6 points) Do exercise 12.6.

              

(For your practice only – you don’t have to hand it in). Try exercise 11.13 on complex numbers.

 

 

 

 

Assignment #2 (10 points) (Due: Monday, March 19, 2007, before the start of the lecture) :

 

 

Required Reading: You should have basic knowledge of UML class diagrams, as well as concepts of inheritance and aggregation and how to model them using UML. All the UML topics discussed in the following link will form a component of your final exam (except “Dependency” and “Interfaces”): http://www.objectmentor.com/resources/articles/umlClassDiagrams.pdf

You are free to use any other UML guides available on the internet. The Rational Rose UML modeling software is available in the CIS undergraduate lab for hands on UML design practice. For home use, you can download the free BOUML toolbox here: http://bouml.free.fr/

 

Q1) (4 points) Do exercise 8.30. Note that the strcmp function has to be implemented using C-style, pointer-based strings. For practice, do exercise 8.9 (8.9 does not have to be handed in)

 

Q2) (6 points) Do exercise 9.12. It requires that you do exercise 9.11 first, but you should only hand in the version of Class Rectangle which corresponds to 9.12.

 

 

Assignment #1 (10 points) (Due: Monday, February 12, 2007, before the start of the lecture) :

 

Q1) (4 points) Do exercise 6.40 on page 321. Modularize the function “Power”.

 

Q2) (6 points) Do exercise 7.32. Hint: You may need to keep track of the string length somehow.

 

 

4) How to turn in homework

  • Turn in ALL the required materials needed for grading at class-time on the due date.
  • By default the following must be returned:
    • Hard Copy:
      • Page 1. A clearly written text stating the following things:

§                                                         Course name

§                                                         Assignment number

§                                                         Your name

§                                                         Your email address

§                                                         Date

      • Page 2--n. Hard copy of all the source files that you wrote (e.g. Assign1.cpp) and output. If you have multiple files, make sure you write the file name on the first page of each file. If you are printing from Unix, the lpr -p print command will do this for you.
    • Soft Copy:
      • Email me a file ( [your_lastname_AssignmentNumber.zip or your_lastname_AssignmentNumber.rar] together with your hard copy. Use the WinZip or the WinRar utilities to zip your files. I will not accept unzipped or unRAR’ed files. The file should be emailed to javedf@cis.uab.edu before the start of the lecture on the due date. The file should include the following files:
        • Readme file (explains how to set up, compile and run your program)
        • Sources files (the files you wrote)
        • Test files
        • Output files (test results)
        • Makefile (optional)
    • Note: Please staple your hard copy and put it in an envelope. On the envelope write your name and assignment number.

4) C++ Resources


Send comments to the CS 304 TA