Assignment 4

CS 368, Fall 2009


Send e-mail questions to Mahesh, kvmakes@cs.wisc.edu
Due Wednesday October 28, by 12 noon.


Collaboration Policy

For this assignment, you may work in pairs (2 people). All students (whether working in a pair or not) must individually turn in the assignment by individually running the handin program. Therefore, 2 copies of the assignment will be turned in for those working as a pair. The grader will choose to grade only one copy of a pair's work, and assign the same score to both students.

If working in a pair, the names of BOTH students must appear at the top of the turned in assignment.


Program

The purpose of this program is to write some C++ code, as part of a program that uses pointers, structures, objects, and needs a copy constructor.

Program Statement

We have written most of a C++ program for you. It implements a Queue class, and elements of the queue are the toy implementation of Process objects.

The main program is a vehicle for testing the Queue and Process classes, so it manipulates Queue objects as well as the Process objects that a queue holds.

The code for this programming assignment are in the 5 files:

Copy each of these files to your own directory. You will modify Queue.cpp and main.cpp for this assignment. Do not change any files other than these two, as you will not be turning in the other files, and your code must work with the other files in their original form. Missing from the program are implementations (definitions) of 3 Queue member functions: enqueue, dequeue, and the copy constructor. Add them, and modify main() such that it tests all 3 of these completed functions.

Note that we are completely ignoring proper memory management for this program. This assignment is intended only to give practice programming in C++, and using pointers. You will get your chance to properly implement memory managment in assignment 6.

Notes

  1. For this assignment, do all your work (especially compilation) on the instructional Unix machines. To be extra careful, work on the 32-bit machines (there are more of them).
  2. To compile a C++ program, use the compiler accessed with g++ on the instructional Unix machines. Your program is expected to compile without warnings or errors when using g++. If the name of a single C++ source code program were p1.cpp, then the Unix command
    g++ p1.cpp
    will compile this program, placing the executable program in the file a.out. Note that this command (given in this manner) must be executed while your current working directory (often abbreviated cwd) is the one containing the C++ source code file. To place the executable in a file other than a.out, add another option and argument to the command line:
    g++ p1.cpp -o executablename

    To compile a multifile program, list all the .cpp files in the compilation command. So, to compile the this assignment's program, you may use the command
    g++ main.cpp Process.cpp Queue.cpp -o tryit
    
    where your executable will then be named tryit.

    And, if you know lots about compilers, please do not set any flags or other options when compiling. We want to see no warnings or errors when we compile with g++.
  3. To run a program, the name of the executable becomes the command. If your executable is named a.out, then the Unix command to execute this program will be
    a.out
    or
    ./a.out
  4. A note to those very few students who do not read carefully: the machine route66 is NOT one of the instructional machines assigned for use by this class. In fact, it is a different platform, and its compilers are linked differently.

Grading

To receive the grade of Credit for this class, this program must receive a minimum score of 70/100. To achieve the 70% score, the program must compile, such that it can be executed.

It should also mostly

Handing In the Program

We are using the lab-supported handin program, to turn in programs online.

You are modifying and turning in two files. We have all the other files, and we will use our copies when compiling and testing your program.

Your source code files turned in will be Queue.cpp and main.cpp. Turn in your program by running the lab-supported handin program. Instead of following the lab's directions, use this exact command


  /s/handin/bin/handin -c cs368-1 -a a4 -d . 

while your current working directory is the one containing the two source code files. This program copies the specifically named file to a directory accessible by the instructor and TA.

Some advice, as this is the first assignment turned in online: