This website is preserved for historical and scholarly reference and is no longer actively maintained.
CpSc 241, Section 1
Assignment 4
9 February 2000
Due: Wednesday, February 16 at midnight
Late penalties: 20 points per partial day late. That is, programs
turned in after midnight Wednesday and before midnight Thursday
will have 20 points deducted for late, programs turned in after
midnight Thursday and before midnight Friday will have a total
of 40 points deducted for late, etc.
Total point value of assignment: 100 points
Late submissions not accepted after: Sunday, February 20 at midnight
This assignment is to be done INDIVIDUALLY.
Create a directory, A4, which will contain all parts of this assignment.
You will need class ListNode, class ListItr, and class List from the text.
You will also need
class Stack (description below) and
a4.cpp (your main program)
The objectives of this program are to give you some more experience
using code "off the shelf" or designed by others and reinforce
construction of a stack using only the methods of singly linked list.
You are to use the classes ListNode, ListItr, and List from the text
without making any changes to these classes.
The methods to be implemented for a Stack are found in the interface
given in Figure 3.41 on page 94, but do not include the struct ListNode.
Place the interface in a file Stack.h, such as
// File name: Stack.h
#ifndef _Stack_H_
#define _Stack_H_
#include "ListNode.h"
#include "ListItr.h"
#include "List.h"
template
class Stack
{
public:
Stack( ) { };
Stack ( const Stack & rhs ) : L ( rhs.L ) { };
~Stack ( );
bool isEmpty ( ) const;
bool isFull ( ) const;
const Object & top ( ) const;
void makeEmpty ( );
void pop ( );
void push ( const Object & x );
Object topAndPop ( );
const Stack & operator= ( const Stack & rhs );
private:
List