-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddUpdateCommand.cpp
More file actions
31 lines (27 loc) · 851 Bytes
/
addUpdateCommand.cpp
File metadata and controls
31 lines (27 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// Created by SpeedyNS on 10/12/2019.
//
#include "addUpdateCommand.h"
addUpdateCommand::addUpdateCommand(phoneBook &bookIn, std::istream &inStream, std::ostream &outStream)
: bookCommand(inStream, outStream), book(bookIn)
{
}
void addUpdateCommand::execute()
{
std::string tempName;
std::string tempNumber;
std::string tempEmail;
tempName = promptLine("Enter name to add/update");
tempNumber = promptLine("Enter phone number");
tempEmail = promptLine("Enter e-mail address");
if(book.find(tempName))
{
outputString("Updating phone book entry for " + tempName);
book.insert(tempName, tempNumber, tempEmail);
}
else
{
outputString("Adding phone book entry for " + tempName);
book.insert(tempName, tempNumber, tempEmail);
}
}