UMBC CS 202, Fall 00
UMBC CMSC 202 Fall '00 CSEE | 202 | 202 F'00 | lectures | news | help

Project 3: A Command History

Release Date

October 25, 2000

(Note: Any changes to this project description since the release date will be posted in this color (green) and italicized.)

This document was last modified on Monday, 27-Nov-2000 15:06:36 EST

Due Date

Midnight Friday, November 10, 2000. Note that this means before 23:59:59 on Friday evening. The standard project late policy applies.

The due date of this project will NOT be extended due to brief system downtimes. Plan your time carefully.

Objectives

The objectives of this project are to:

The Problem

When working with a computer through a command line interface, it is often helpful to be able to repeat commands that were executed previously in the current session. Often commands are long strings that are prone to typing errors when reentered. This type of functionality is often called a command history. For proj3, you will be implementing a very simple shell that includes a useful history function.

Requirements

Your program MUST do each of the following.
  1. Process the following commands:

    These commands are explained in detail in the "Command Processing" section below.

  2. Implement a Stack class that contains the following operations.

    In addition, the class must contain the "big four" (a default constructor, an assignment operator, a copy constructor, and a destructor). You may include other operations as you see necessary, but the above list MUST be included.

  3. Implement a History class that contains the following operations.

    In addition, the class must contain the "big four" (a default constructor, an assignment operator, a copy constructor, and a destructor). You may include other operations as you see necessary, but the above list MUST be included.

  4. Implement your History class as a pair of stacks. Use one stack object to hold the command history and another as temporary storage while searching through the history. Aside from the stacks, you may only include data members of primitive types in your history. For example, you may use ints and floats, but not Lists and Queues (whether you wrote them or not). Note that for this project, a pointer to a non-primitive type will be considered a non-primitive type.
  5. Allow for an "infinite" history. That is, your history should not impose a size limit that is either hardcoded or set at the time it is instantiated. Note that if a stack can increase its size dynamically to make room for new elements, the result of isFull() for your stack will always be false.
  6. Use multiple files to separate main(), class header files, class method implementations, auxilliary functions, and auxilliary function prototypes.
  7. Properly deallocate all dynamically allocated memory.

Note that no suggestions for the implementations (i.e., data members) of the Stack clas has been given. Those choices are up to you.

Command Processing

The commands that the program must be able to process are explained below.

All of the commands must be checked for correct syntax. A command is considered syntactically correct if it appears on a line by itself (i.e., has no trailing non-whitespace characters) and matches one of the above commands. Note that it is ok for a command to contain multiple white spaces before the command or after the command. All commands, whether syntactically correct or not, should be entered into the history.

Use of the system() Function

In order to run the history commands after they have been processed and entered into the history, you will need to use the system() function. You will need to #include the stdlib.h header file in order to use this function. A sample program that uses the system function can be found here. See "man system" for more information on this function.

Extra Credit (10 points)

The command cd is not a program but is actually a command that is built into the shell itself. Your program will not support cd by default. Add extra cases to your program to handle the cd command. The sample program currently handles this command and will illustrate the kind of error handling you should have for things like bad directory names, etc.

This is extra credit for your project grade. The course staff WILL NOT help you with the extra credit portion of your grade in any way. You must come up with the solution for this on your own. The course staff can answer general programming questions, but once a staff member determines that you're asking about the extra credit question they may decline to answer the question.

Good luck.

Sample Program

A sample executable is available in the directory

/afs/umbc.edu/users/j/k/jkukla1/pub/cs202/fall00/Project4/

on the irix.gl.umbc.edu systems. Please use it to help understand how the program should behave under certain conditions before coming to your instructor. And when in doubt, make it behave like the sample program!

Note: The program is an executable file compiled for irix, so the odds are fairly high that it won't run as is on your home machine.

Coding Standards

You MUST follow the CMSC 202 coding standards. Read them thoroughly and carefully.

Using Code You Didn't Write

Claiming authorship of code that you didn't write is plagiarism and will be dealt with as academic dishonesty. You should avoid using code that you did not write; it defeats the learning experience of the project. If you do use outside code in your project, you must cite the source. If a significant portion of the project comes from an outside source, your grade may be reduced.

Testing Your Program

Remember, your program must compile and run using the CC compiler on the IRIX machines (irix1.gl.umbc.edu or irix2.gl.umbc.edu). If your program does not compile or does not generate the correct output, you will not receive full credit for this project.

Your Makefile

Many systems come with a utility called "make" which helps simplify project compilation. For this class you are required to use make for each project. The way this is done is by using a "makefile" that tells the make utility what to do when compiling your program.

You may use this sample makefile for this project. You should make sure that you have a makefile named either makefile or Makefile and that when you type make your program compiles to an executable called proj3. Failure to follow these simple directions will result in a reduced grade.

Grading

The grade for this project will be broken down as follows: 50% Correctness This tests that your program behaves the same way that the sample does. 30% Design and Style You should follow the coding standards and make sure your coding style is consistent. 20% Documentation Commenting source code inline as well as header files. A breadown that the graders will receive when they go to grade your project is provided here.

What to Turn In

You should submit your Makefile and all files needed to build your program.

Submitting Your Project

When you have finished and tested your project, you can submit it electronically using submit. The project name for this assignment is proj3. As an example, to submit your files, you would type: submit cs202 proj3 Makefile file.1 file.2 ... file.n More complete documentation for submit and related commands can be found here. You should replace all of the file.x's above with your real file names.


CSEE | 202 | 202 F'00 | lectures | news | help