# Introduction

In today’s lab you will make a tiny phone book application. I’ve given you some starter code, but you still have a ways to go.

# Problem 0: Clean up after yourself

You know the drill.

Except this time, we’ve given you a couple of simple .gitignores. Just make sure to keep your repositories clean!

You will lose points…

1. If you delete the .gitignores we gave you1.
2. If you commit compiled files, editor droppings, data files, or other junk.

# Problem 0.5: Build the Thing

1. Use qmake and make to build the project.
2. Make sure it runs!

# Problem 1: A New Signal

1. newNumber needs a signal that it can use to send new phone number information to PhoneBook.
2. Implement newNumber::addPress() to send a signal to PhoneBook with a number to add.
3. PhoneBook needs to connect newNumber’s signal to a new slot.

Hints:

• Entry is a QWidget.
• If you want to pass an object through a signal, it is best to pass a pointer to something on the heap, rather than trying to pass it by value.
• PhoneBook::entries keeps track of all the Entry widgets, so all new Entry widgets you create need to be added to it.
• New Entry widgets also need to be added to PhoneBook::layout, so that they actually show up on screen.

At this point, you should stop and make sure that your code properly displays new phone numbers in the UI whenever you click the ‘Add’ button.

# Problem 2: Saving and Opening

Now that you can add entries to your phone book, let’s add features, so that the user is able to save and open a phone book.

1. Add a File menu to PhoneBook
• The File menu needs Open, Save, and Quit entries.
2. Finish implementing deserialize().
3. Finish the slots for Open and Save (see TODOs).
4. Make Quit prompt you before quitting if you haven’t saved changes.

Hints:

• serialize() converts all the Entrys to a string that can be then written to a text file.
• deserialize() should read data from a string and convert it back into a bunch of Entrys.
• We can serialize Entrys into a string; save the string to a file; load the string from a file; and deserialize the string back into a bunch of Entrys.
• This is how most programs (Word, PowerPoint, etc.) save data to disk. They use a sophisticated method for serialization.

# Epilogue

• The layout of your project. You will lose points if…
• …files are not named as specified.
• …files or directories are not present in the expected locations documented at the bottom of this write-up.
• The presence of a useful .gitignore and absence of junk files.
• For all problems:
• Your code’s got to compile
• The quality / style of your C++ code is good
• Be sure to comment your code!
• All TODO comments must be addressed
• As in, you’ve implemented the thing that’s missing. Simply deleting the TODO comment is insufficient…
• Problem 1
• Your program functions as described
• The user can insert new numbers
• Problem 2
• Your program functions as described
• The user can save and open phone books
• The user is prompted if they quit

## Submissions

As always, your git repo on http://git-classes.mst.edu is your submission. Don’t forget to commit and push all relevant files. Make sure you see everything you expect on GitLab!

We expect to see the following files on your master branch:

• .gitignore
• README.md
• example/
• There’s a lot of stuff in here. There’s no need to change any of it.
• Just don’t add any junk files.
• lab/
• .gitignore
• entry.cpp
• entry.h
• main.cpp
• newNumber.cpp
• newNumber.h
• phonebook.cpp
• phonebook.h
• phonebook.pro
1. Whyyyy would you do that?