The class template should use a private array to store the elements in the set.
It should have a constructor
ASet(int size)
which creates an instance of ASet with no members, but with the size of the array
equal to size.
Your program should have these parts:
The program executes a loop which does:
It asks the user for a command, which can be one of the following:
C 'name'
A 'name' 'string'
D 'name' 'string'
E 'name'
I 'name' 'string'
N 'name1' 'name2'
U 'name1' 'name2'
Q
The C command creates a new empty set whose name is 'name' unless a set
with that name already exists, in which case it gives an error message.
The A command adds 'string' to the set 'name' if it is not full and 'string' is not
already a member of 'name', else it gives an error message.
The D command deletes 'string' from the set 'name' if it is a member,
else it gives an error message.
The E command indicates whether the set 'name' is empty.
The I command indicates whether 'string' is in the set 'name'.
The N command performs the intersection of set 'name1' with set 'name2',
putting the result in 'name1'.
The U command performs the union of set 'name1' with set 'name2',
putting the result in 'name1'.
The Q command ends the program.
There are other kinds of errors to consider.
A sample run of the program might look like this (you don't have to use
the same format):
Please enter a command (C, A, D, E, I, N, U, Q):
>C words
The set words has been created.
Please enter a command (C, A, D, E, I, N, U, Q):
>E words
The set words is empty.
>A words Hi
Please enter a command (C, A, D, E, I, N, U, Q):
>E words
The set words is not empty.
Please enter a command (C, A, D, E, I, N, U, Q)):
>A words there.
Please enter a command (C, A, D, E, I, N, U, Q):
>D words Hi
Please enter a command (C, A, D, E, I, N, U, Q):
>I words Hi
String "Hi" is not in the set words.
Please enter a command (C, A, D, E, I, N, U, Q):
>I words there.
String "there." is in the set words.
Please enter a command (C, A, D, E, I, N, U, Q):
>D words Hi
String "Hi" is not in the set words and cannot be deleted.
Please enter a command (C, A, D, E, I, N, U, Q):
>C more
The set more has been created.
Please enter a command (C, A, D, E, I, N, U, Q):
>A more Hi
>U words more
>I words Hi
String "Hi" is in the set words.
Please enter a command (C, A, D, E, I, N, U, Q):
>Q
Goodbye.
Turn in:
Within this individual directory, create a subdirectory named p1. Copy all your source files and the executable file p1 into your p1 directory, including header files, but no object files. So, for example, if your login name was smithjd then your source files and the executable file p1 should be copied to /afs/cu/class/cs344jl/smithjd/p1. These directories have permissions set so that no one other than yourself and Prof. Lynch can read the files. You may, of course, use whatever operating system and compiler you wish to develop your code, but the version you turn in, both hardcopy and the files submitted to AFS, must compile with g++ and run under polaris.
Your grade on the program will be based on: