| Overview | We will create a phonebook application that
will store name, number pairs,
allow lookup by name or number, and
provide persistent storage of data between application uses.
This assignment will provide experience with: |
|
|---|---|---|
| Getting Started | To get started several things must be done:
|
|
In the following commands the # deonotes
a comment, you do not need to type the comment with
the command.
Update the shared working copy. cd # Go to your home directory cd cs23021_shared # Go into the shared working copy svn update # Do the update Create directory for the project. cd # Go to your home directory cd cs23021 # Go into your working copy svn mkdir Phonebook # Create dir for the project ll # Notice the new directory svn commit -m "Phonebook project directory" # Commit
A file with the Copy the file phonebook_main.cpp. cd # Go to your home directory cd cs23021 # Go into your working copy cd Phonebook # Go into new directory cp ../../cs23021_shared/Phonebook/phonebook_main.cpp . # Copy provided file svn add phonebook_main.cpp # Add file with main svn commit -m "Phonebook project provided file" # Commit Copy the Makefile. cd # Go to your home directory cd cs23021 # Go into your working copy cd Phonebook # Go into Phonebook directory cp ../../cs23021_shared/Phonebook/Makefile . # Copy make file to current dir svn add Makefile # Add make file svn commit -m "Phonebook project make file" # Commit Create empty files to get started. touch phonebook.h phonebook.cpp # Create empty files svn add phonebook.h phonebook.cpp # Add empty files svn commit -m "Empty initial files" # Commit Implement as described below. |
||
| Files | Three files are used:
|
|
| Provided | The following functions are in the provided file: | |
int main();
|
||
void displayPrompt();
|
||
Note that you do not write a
main()
function.
|
||
| Structures | Use the following two structures:
struct PB_Entry
{
std::string _name;
int _number;
};
struct Phonebook
{
std::string _file_name;
std::vector<PB_Entry> _entries;
};
|
|
| Functions | Put the structure definitions and function declarations in the file
phonebook.h.
Define the following functions in the file phonebook.cpp. |
|
void input(Phonebook&);
|
||
|
||
int lookupName(const Phonebook&, const std::string&)
|
||
|
||
int lookupNumber(const Phonebook&, int) |
||
|
||
void addToLists(Phonebook&, const std::string&, int)
|
||
|
||
void outputAll(const Phonebook&)
|
||
|
||
void save(const Phonebook&)
|
||
|
||
| Compiling | Commands the make file provides:
make # Compile the program, executable is named phonebook make pbfile # Generate an phonebook file named pb.txt make clean # Remove .o files and the executable |
|
| Running | Run by specifying the phonebook file on the command line:
./phonebook phonebook_file |
|
| Implementing | Suggested implementation stages. | |
|
||
| Requirements | The
general program requirements
apply.
| |
| Turning In | Do the following:
|