(Solved Homework): This project will help you show your mastery of arrays, C-strings, classes, and libraries. Write a program to handle a user's rolodex entries. (A rolo…

C++ need help programming something like this? 

Don't use plagiarized sources. Get Your Custom Essay on
(Solved Homework): This project will help you show your mastery of arrays, C-strings, classes, and libraries. Write a program to handle a user's rolodex entries. (A rolo…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

This project will help you show your mastery of arrays, C-strings, classes, and libraries. Write a program to handle a user’s rolodex entries. (A rolodex is a system with tagged cards each representing a contact. It would contain a name, address, and phone number. In this day and age, it would probably have an email address as well.) Typical operations people want to do to a rolodex entry are: 1) Add entry 2) Edit entry 3) Delete entry 4) Find entry 5) Print all entries 6) Quit You can decide what the maximum number of rolodex entries is and how long each part of an entry is (name, address, etc). When they choose to edit an entry, give them the option of selecting from the current rolodex entries or returning to the main menu – don’t force them to edit someone just because they chose that option. Similarly for deleting an entry. Also don’t forget that when deleting an entry, you must move all following entries down to fill in the gap. If they want to add an entry and the rolodex is full, offer them the choice to return to the main menu or select a person to overwrite. When they choose the print option, make a nicely formatted table of their current entries (if any). (See the class roster lab for an example of a fine table format – and possible gotcha’s.) When they choose to find an entry, go to a submenu: 1) find by Name 2) find by Address 3) find by Phone number 4) find by Email address 5) Return to Main Menu All of these searches are to be case-insensitive content searches. (In other words, if the rolodex contains a person named Vishal Herrera, they should be found by searches by name of: sh SH al h al H herrera HERRERA, etc. as well as of Vishal Herrera.) Question: Should you print all matches to a search or just the first one? All menus are to be choosable by both number and capitalized letter(s).

Expert Answer

 

RolodexEntryManager.cpp
————————————-
#include <iostream>
#include “RolodexEntry.h”
#include <vector>
#include <climits>
#include <cctype>

using namespace std;

//function dec
void printMainMenu();
void printEditMenu(vector<RolodexEntry> & list);
void editContactSub(const short c, vector<RolodexEntry> & list);
void printSearchMenu(vector<RolodexEntry> & list);
void printList(vector<RolodexEntry> & list);
void eraseEntry(vector<RolodexEntry> & list, short index);

int main(void)
{
bool isRunning = true;
vector<RolodexEntry> list;
do
{
char c;
printMainMenu();
cin >> c;
cin.ignore(INT_MAX, ‘n’);
switch(tolower(c))
{
case ‘1’: case ‘a’:
{
RolodexEntry newEntry;
newEntry.readIn();
list.push_back(newEntry);
break;
}
case ‘2’: case ‘e’:
{
printEditMenu(list);
break;
}
case ‘3’: case ‘d’:
{
printList(list);
cout << “nSelect Contact to delete:”;
if(cin.fail())
{
cin.clear();
cin.ignore();
}
short c;
cin >> c;

eraseEntry(list, c-1);//resizes and moves back
break;
}
case ‘4’: case ‘s’:
{
printSearchMenu(list);
break;
}
case ‘5’: case ‘p’:
{
printList(list);
break;
}
case ‘6’: case ‘q’:
{
isRunning = false;
break;
}
default:
{
cout << “Invalid selection.”;
break;
}
}
}while(isRunning);

return 0;
}
void printMainMenu()
{
cout << “nMain Menunn”
<< “1. Add contactn”
<< “2. Edit contactn”
<< “3. Delete contactn”
<< “4. Search contactsn”
<< “5. Print all contactsn”
<< “6. Quitn”;
return;
}
void printEditMenu(vector<RolodexEntry> & list)
{
cout << “nn”;
printList(list);
cout << “nSelect Contact to edit:”;//read in choice
if(cin.fail())
{
cin.clear();
cin.ignore();
}
short c;
cin >> c;
cin.ignore(INT_MAX, ‘n’);
editContactSub(c, list);
return;
}
void editContactSub(const short c, vector<RolodexEntry> & list)//and work
{
short index = c;
if(index >= 0 && index < list.size())//it’s gooooood!
{
RolodexEntry edited = list[static_cast<short>(c)-1];

//edit menu
cout << “1. edit First namen”
<< “2. edit Last namen”
<< “3. edit Addressn”
<< “4. edit Phone numbern”
<< “5. edit Emailn”;
char sel;
cin >> sel;
cin.ignore(INT_MAX, ‘n’);

switch(tolower(sel))
{
case ‘1’: case ‘f’:
{
cout << “nEnter new first name: “;
string newName;
cin >> newName;
edited.setFName(newName);
break;
}
case ‘2’: case ‘l’:
{
cout << “nEnter new last name: “;
string newName;
cin >> newName;
edited.setLName(newName);
break;
}
case ‘3’: case ‘a’:
{
cout << “nEnter new street number and street: “;
string newStreet;
cout.flush();
if (cin.peek() == ‘n’)
{
cin.ignore();
}
getline(cin, newStreet);
edited.setStreet(newStreet);

cout << “nEnter new town: “;
string newtown;
cout.flush();
if (cin.peek() == ‘n’)
{
cin.ignore();
}
getline(cin, newtown);
edited.setTown(newtown);

cout << “nEnter new state: “;
string newstate;
cout.flush();
if (cin.peek() == ‘n’)
{
cin.ignore();
}
getline(cin, newstate);
edited.setState(newstate);

cout << “nEnter new zipcode: “;
long newzip;
cin >> newzip;
if(newzip > 99999)//long zip
{
edited.setZip(newzip);
edited.setSZipLong();//finds szip from long zip
}
else
{
edited.setSZip(newzip);
}
break;
}
case ‘4’: case ‘p’:
{
cout << “nEnter new areacode: “;
short newarea;
cin >> newarea;
edited.setArea(newarea);

cout << “nEnter new exchange number: “;
short newex;
cin >> newex;
edited.setExchange(newex);

cout << “nEnter new line: “;
short newLine;
cin >> newLine;
edited.setPLine(newLine);
break;
}
case ‘5’: case ‘e’:
{
cout << “nEnter new email: “;
string newemail;
cin >> newemail;
edited.setEmail(newemail);
break;
}
}
}
else
{
cout << “Contact at this index does not exist.”;
}
return;
}
void printSearchMenu(vector<RolodexEntry> & list)//and work
{
cout << “1. search by Namen”
<< “2. search by Addressn”
<< “3. search by Phone numbern”
<< “4. search by Emailn”
<< “5. Return to Main menun”;

char c;
cin >> c;
cin.ignore(INT_MAX, ‘n’);
switch(tolower(c))
{
case ‘1’: case ‘n’:
{
cout << “nEnter search term: “;
string search;
cout.flush();
if (cin.peek() == ‘n’)
{
cin.ignore();
}
getline(cin, search);

for(vector<RolodexEntry>::size_type i = 0; i < list.size(); i++)
{
if(list[i].getFName().find(search) != string::npos ||
list[i].getLName().find(search) != string::npos)
{
list[i].printEntry();
}
}
break;
}
case ‘2’: case ‘a’:
{
cout << “nEnter search term: “;
string search;
cout.flush();
if (cin.peek() == ‘n’)
{
cin.ignore();
}
getline(cin, search);

for(vector<RolodexEntry>::size_type i = 0; i < list.size(); i++)
{
if(list[i].getStreet().find(search) != string::npos ||
list[i].getTown().find(search) != string::npos ||
list[i].getState().find(search) != string::npos)
{
list[i].printEntry();
}
}
break;
}
case ‘3’: case ‘p’:
{
cout << “nEnter part of phone number (last four digits gives best results): “;
short search;

while(cin.fail())
{
cin.clear();
cin.ignore();
}
cin >> search;

for(vector<RolodexEntry>::size_type i = 0; i < list.size(); i++)
{
if(list[i].getArea() == search || list[i].getExchange() == search ||
list[i].getPLine() == search)
{
list[i].printEntry();
}
}
break;
}
case ‘4’: case ‘e’:
{
cout << “nEnter email: “;
string search;
cout.flush();
if (cin.peek() == ‘n’)
{
cin.ignore();
}
getline(cin, search);

for(vector<RolodexEntry>::size_type i = 0; i < list.size(); i++)
{
if(list[i].getEmail().find(search) != string::npos)
{
list[i].printEntry();
}
}
break;
}
case ‘5’: case ‘q’:
{
break;
}
default:
{
cout << “nInvalid seletion.”;
break;
}
}
}
void printList(vector<RolodexEntry> & list)
{
cout << ‘n’;
for(vector<RolodexEntry>::size_type i = 0; i < list.size(); i++)
{
cout << i+1 << “.”;
list[i].printEntry();
}
return;
}
void eraseEntry(vector<RolodexEntry> & list, short index) {
vector<RolodexEntry>::size_type pos = index – 1;
vector<RolodexEntry>::size_type k;

if (pos < list.size() && pos >= 0) {
for (k = pos + 1; k != list.size(); k++) {
list[k – 1] = list[k];
}
list.pop_back();
} else {
cout << “Out of bounds.”;
}
return;
}
—————————————————————–
RolodexEntry.cpp
——————————
#include “RolodexEntry.h”
#include <iostream>

using namespace std;

void RolodexEntry::printEntry()
{
cout << “nName: ” << fName << ” ” << lName;
cout << “nAddress: ” << street <<
“n” << town << “, ” <<
state << ‘ ‘;
if(zip != 0)
{
cout << zip;
}
else
{
cout << szip;
}
cout << “nPhone: (” << area << ‘)’ << exchange << ‘-‘ << line << “n”;
}
void RolodexEntry::readIn()
{
cout << “nEnter new contact’s first name:n”;
cin >> fName;
cout << “nEnter new contacts’s last name:n”;
cin >> lName;
cout << “nEnter new contacts’s address (number and street):n”;
cout.flush();
if (cin.peek() == ‘n’)
{
cin.ignore();
}
getline(cin, street);

cout << “nEnter new contacts’s town:n”;
cout.flush();
if (cin.peek() == ‘n’)
{
cin.ignore();
}
getline(cin, town);

cout << “nEnter new contacts’s state:n”;
cout.flush();
if (cin.peek() == ‘n’)
{
cin.ignore();
}
getline(cin, state);

cout << “nEnter new contacts’s zipcode:n”;
long tempZip;
cin >> tempZip;
if(tempZip > 99999)//long zip
{
zip = tempZip;
setSZipLong();//finds szip from long zip
}
else
{
szip = tempZip;
}
cout << “nEnter new contacts’s phone number (separated by spaces):n”;
cin >> area >> exchange >> line;
cout << “nEnter new contacts’s email:n”;
cin >> email;
}
———————————————————————-
RolodexEntry.h
—————————————–

#ifndef ROLODEXENTRY_H_INCLUDED
#define ROLODEXENTRY_H_INCLUDED

#include <string>
//using namespace std;
//base project only
class RolodexEntry
{
private:
std::string fName, lName, street, town, state;
long zip;
short szip, area, exchange, line;
std::string email;
public:
RolodexEntry(void):fName(), lName(), street(), town(),
state(), zip(000000000), szip(00000),
area(0), exchange(0), line(0), email() {}
RolodexEntry(std::string fname, std::string lname):street(), town(),
state(“”), zip(000000000),
szip(00000), area(0),
exchange(0), line(0), email() {}
RolodexEntry(const RolodexEntry & r):fName(r.fName), lName(r.lName),
street(r.street), town(r.town),
state(r.state), zip(r.zip), szip(r.szip),
area(r.area), exchange(r.exchange),
line(r.line), email(r.email) {}

std::string getFName() const {return fName;}
void setFName(std::string first){fName = first;}
std::string getLName() const {return lName;}
void setLName(std::string last){lName = last;}
std::string getStreet() const{return street;}
void setStreet(std::string str){street = str;}
std::string getTown() const {return town;}
void setTown(std::string newtown){town = newtown;}
std::string getState() const {return state;}
void setState(std::string newstate){state = newstate;}
long getZip() const {return zip;}
void setZip(long newzip){zip = newzip;}
short getSZip() const {return szip;}
void setSZipLong(){szip = zip / 10000;}
void setSZip(short newszip){szip = newszip;}
short getArea() const {return area;}
void setArea(short newarea){area = newarea;}
short getExchange() const {return exchange;}
void setExchange(short exch){exchange = exch;}
short getPLine() const {return line;}
void setPLine(short newline){line = newline;}
std::string getEmail(){return email;}
void setEmail(std::string Email){email = Email;}

void printEntry();//other fns
void readIn();
bool isEqual(RolodexEntry e){return e.fName == fName && e.lName == lName &&
e.street == street && e.town == town &&
e.state == state && e.zip == zip && e.szip == szip &&
e.area == area && e.exchange == exchange && e.line == line &&
e.email == email;}
};

#endif // ROLODEXENTRY_H_INCLUDED

Homework Ocean
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents