CISC181 honors, Fall 2005, Lab09


  1. Send an email to myself and to Kevin confirming either (a) who you are working with on project 2 (towers of hanoi) or (b) that you are working by yourself. (10 pts)
  2. Together with your lab partner, or by yourself, come up with the member functions for Disk_C and Tower_C. Write these in separate files disk.h and tower.h.

    You do NOT need to come up with the private part yet. We'll talk about that part in class on Wednesday.

    If you are programming in pairs, one of these files should be authored by person1, and the other should be authored by person2 (though in reality, you'll be collaborating a great deal!)

  3. Collaborate on a main program something like this:
     #include <iostream>
     using namespace std;
    
     #include "disk.h"
     #include "tower.h"
    
     int main(int argc, char *argv[])
     {
       if (argc!=2)
       {
         cerr << "Usage: " << argv[0] << " numdisks" << endl;
         exit(1);
       }
    
       numDisks = atoi(argv[1]); // get number of disks from command line
    
       if (numDisks <= 0)
       {
          cerr << "numDisks must be > 0" << endl;
          exit(2);
       }
    
      cout << "This is where eventually we will solve Towers of Hanoi for "
           << numDisks  
           << " disks. For now, we are just checking syntax of our .h files "
    << endl; return 0; }
  4. Once your .h files actually compile, show them to Kevin. He'll review them and see if there are any issues that you haven't really thought through, and give you advice on whether you need to go back to the drawing board.

    This step is optional but highly recommended.. b/c if you don't do it, you might be losin' some points if your class design isn't really well thought out, or maybe even if it is, but Kevin can't figure out what your thinking was. Realize that your .h file is NOT just code for the compiler...it needs to communicate to thinking living humans what your design is. If Kevin can't figure out your design, it isn't Kevin's problem... it is yours... your code needs to be clear, and your .h file should either be so wonderfully well designed as to be self-documenting, or should contain abundant comments that explain your thinking very clearly and precisely.

    In lab today, you have the opportunity to actually ASK Kevin whether your code is clear, BEFORE he assigns it a grade, so if you don't take advantage of that, its kind of, well, foolish. :-)

  5. For those of you working in pairs, one of you should submit just the .h file that your lab partner is working on... the other person should submit a full script called lab09.txt that shows a cat of both .h files, a cat of your main.cc file, and a compile and run of your main. Demonstrate the main on at least one legal and one illegal value of n, and at least one command line that doesn't match the usage (i.e. too long or too short) You might need to also put in #include for the atoi() function.
Grading:
  10 pts for sending me and Kevin the email
  60 pts for your .h files (30 pts each)
  20 pts for the main() and the script.
  10 pts for following directions