[SOLVED] CS201-# PhoneBook-Project

40.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon PhoneBook-Project-master-kzk67q.zip (11.8 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (2 votes)

1. BelowΒ Β  isΒ Β  theΒ  requiredΒ Β  partΒ  ofΒ Β  theΒ  Person class.Β Β Β  TheΒ  nameΒ  ofΒ Β  theΒ  class mustΒ  beΒ Β Β Β  Person.Β Β Β  TheΒ  interfaceΒ  for
theΒ  class mustΒ  beΒ Β  writtenΒ Β Β  inΒ Β  aΒ Β Β  fileΒ  calledΒ Β Β Β  SimplePerson.h andΒ Β Β  itsΒ  implementationΒ Β Β Β  mustΒ  beΒ Β  writtenΒ Β Β  inΒ Β  a
fileΒ  calledΒ Β Β Β  SimplePerson.cpp.
β€šΓ±β„’ TheΒ Β Β  Person classΒ Β Β  keepsΒ Β Β Β  theΒ  name ofΒ Β  aΒ Β  singleΒ Β Β  person as theΒ  sole data member.Β Β Β Β  Make sure to
implementΒ  theΒ  getΒ  functionΒ Β  forΒ  this dataΒ  memberΒ Β Β Β  since weΒ Β  willΒ  useΒ  it to testΒ  yourΒ  program.
β€šΓ±β„’ ImplementΒ Β Β  theΒ  defaultΒ Β Β  constructor,Β Β Β Β  which initializes theΒ  name dataΒ  member.Β Β Β  Additionally,Β Β Β Β  implement
yourΒ  ownΒ  destructor andΒ  copyΒ  constructor,Β Β Β Β  andΒ  overloadΒ Β  theΒ  assignment operator.Β  AlthoughΒ Β  youΒ Β Β Β  may
useΒ  theΒ  defaultΒ Β Β  onesΒ  forΒ  someΒ  ofΒ Β  these specialΒ Β Β  functions, youΒ  areΒ  advisedΒ Β Β  toΒ Β  implementΒ Β Β Β  themΒ  (some may
haveΒ  noΒ Β  statements) soΒ Β  thatΒ  itΒ Β  willΒ  beΒ Β  easierΒ Β Β Β  forΒ  youΒ  toΒ Β  extendΒ Β Β Β  themΒ  forΒ  PartΒ  B.
β€šΓ±β„’ DoΒ Β Β Β  notΒ  deleteΒ Β Β Β  orΒ Β  modifyΒ Β Β Β  anyΒ  partΒ  ofΒ Β  theΒ  given dataΒ  membersΒ Β Β  orΒ Β  memberΒ Β Β Β  functions. However,Β Β  youΒ  may
defineΒ Β Β Β  additional functionsΒ  andΒ  dataΒ  members,Β Β  ifΒ Β  necessary.
#ifndef __SIMPLE_PERSON_H
#define __SIMPLE_PERSON_H
#include <string>
using namespace std;
class Person {
public:
Person( const string name = “” );
~Person();
Person ( const Person &personToCopy );
void operator=( const Person &right );
string getName();
private:
string name;
};
#endif
2. BelowΒ Β  isΒ Β  theΒ  requiredΒ Β  partΒ  ofΒ Β  theΒ  PhoneBook classΒ  thatΒ  youΒ  mustΒ  write inΒ Β  PartΒ  AΒ Β Β  ofΒ Β Β Β  thisΒ  assignment. The
nameΒ  ofΒ  theΒ  classΒ Β Β Β  must beΒ  PhoneBook. TheΒ  interface forΒ  theΒ  classΒ Β Β Β  must beΒ  writtenΒ Β Β Β  inΒ  aΒ Β  file called
SimplePhoneBook.h andΒ  itsΒ  implementationΒ  must beΒ  writtenΒ Β  inΒ  aΒ Β  file called
2
SimplePhoneBook.cpp.Β Β  Do notΒ Β Β  deleteΒ Β Β  orΒ  modifyΒ Β Β  anyΒ  part ofΒ  theΒ  givenΒ Β Β Β  data membersΒ Β Β Β  orΒ  member
functions. YouΒ  areΒ  notΒ  allowedΒ Β Β  toΒ Β  defineΒ Β Β Β  additional functionsΒ  andΒ  dataΒ  membersΒ Β Β  toΒ Β Β Β  thisΒ  class forΒ  PartΒ  A.
#ifndef __SIMPLE_PHONEBOOK_H
#define __SIMPLE_PHONEBOOK_H
#include <string>
using namespace std;
#include “SimplePerson.h”
class PhoneBook{
public:
PhoneBook();
~PhoneBook();
PhoneBook (const PhoneBook& phoneBookToCopy);
void operator=(const PhoneBook& right);
bool addPerson(const string name);
bool removePerson(const string name);
void displayPeople();
private:
struct PersonNode {
Person t;
PersonNode* next;
};
PersonNode *head;
int numberOfPeople;
PersonNode* findPerson(string name);
};
#endif
YouΒ  mustΒ  keepΒ  theΒ  recordedΒ Β  people inΒ  aΒ Β Β  linked-list ofΒ Β  PersonNodes whose headΒ  pointerΒ Β Β  isΒ Β Β Β  PersonNode*
head. InΒ Β  thisΒ  class definition, youΒ  alsoΒ  seeΒ  theΒ  prototypeΒ  ofΒ Β  aΒ Β Β  privateΒ Β Β  functionΒ Β  calledΒ Β Β Β  findPerson. YouΒ  may
wantΒ  toΒ Β  implementΒ  suchΒ  anΒ Β  auxiliaryΒ  functionΒ Β  andΒ  useΒ  itΒ Β  inΒ Β  yourΒ  addΒ  andΒ  removeΒ Β Β Β  functionsΒ  (then inΒ Β  someΒ  other
functionsΒ  forΒ  Part B).Β  ThisΒ  functionΒ  takesΒ Β Β Β  theΒ  name ofΒ  aΒ Β Β  person,Β Β Β  searchesΒ  itΒ Β  inΒ Β Β Β  theΒ  linkedΒ Β Β Β  listΒ  ofΒ  people,Β Β Β  and
returnsΒ Β Β  aΒ Β  pointerΒ Β  toΒ  theΒ  PersonNode that containsΒ  that person, if theΒ  person existsΒ Β  inΒ Β Β Β  theΒ  system.
Otherwise, itΒ Β  returnsΒ Β Β  NULL. ThisΒ  auxiliaryΒ  functionΒ Β  mayΒ  helpΒ  youΒ  write moreΒ  concise codes.Β Β Β Β  However,Β Β  ifΒ Β  youΒ  do
notΒ  want toΒ  useΒ  it,Β  just defineΒ Β Β  anΒ  emptyΒ Β Β Β  functionΒ  (withΒ Β Β Β  noΒ  statements)Β Β Β Β  inΒ Β Β Β  your SimplePhoneBook.cpp
file.
ThingsΒ Β Β Β  toΒ Β  do:
β€šΓ±β„’ ImplementΒ Β Β  theΒ  defaultΒ Β Β  constructor,Β Β Β Β  which createsΒ Β Β  anΒ Β  empty phonebook. AlsoΒ  overloadΒ Β  theΒ Β Β Β  assignment
operatorΒ Β  andΒ  implementΒ  theΒ  destructor andΒ  copyΒ  constructors.
β€šΓ±β„’ ImplementΒ Β Β  theΒ  addΒ  andΒ  removeΒ Β Β Β  person functions whose detailsΒ Β Β  areΒ  given below:
AddΒ  aΒ Β  person: ThisΒ Β Β  functionΒ  adds aΒ Β  person to theΒ  system.Β Β  TheΒ  name ofΒ  theΒ  person isΒ Β  specified asΒ  a
parameter. InΒ Β  thisΒ  system,Β Β Β  person namesΒ Β Β Β  areΒ  unique.Β Β Β  Thus, ifΒ Β  theΒ  userΒ  attemptsΒ Β  toΒ Β  addΒ Β Β Β  aΒ Β Β  person with an
alreadyΒ Β Β  existingΒ Β  name, doΒ Β  notΒ  addΒ  theΒ  person and returnΒ Β Β Β  false.Β Β Β Β  Otherwise, ifΒ Β  theΒ Β Β Β  person does notΒ  exist in
theΒ  system,Β Β Β  addΒ  theΒ  person toΒ  theΒ  systemΒ Β Β Β  andΒ  returnΒ Β Β Β  true. DOΒ Β  NOTΒ  displayΒ Β Β  anyΒ Β Β Β  warningΒ Β Β  messages. Note
thatΒ  names areΒ  caseΒ  insensitive (i.e.,Β Β Β  MachineΒ Β Β  LearningΒ Β  andΒ  MACHINEΒ Β Β  LEARNINGΒ Β  areΒ  theΒ  sameΒ  thing).
YouΒ  can’tΒ Β Β Β  useΒ  anyΒ  additional outsideΒ Β  resources forΒ  comparing strings,Β  youΒ  shouldΒ Β Β  onlyΒ  useΒ  standard
libraries.
3
RemoveΒ Β Β Β  aΒ Β  person: ThisΒ Β Β  functionΒ  removesΒ Β  aΒ Β  person fromΒ Β Β Β  theΒ  system.Β Β  TheΒ  name ofΒ Β Β Β  theΒ  person to be
deleted is specifiedΒ  asΒ Β  aΒ Β Β  parameter. IfΒ Β  theΒ  person with theΒ  given nameΒ  existsΒ Β Β Β  inΒ Β  theΒ Β Β Β  system,Β Β Β  removeΒ Β Β Β  it
fromΒ  theΒ  systemΒ Β Β Β  andΒ  returnΒ Β Β Β  true. Otherwise, ifΒ Β  there isΒ Β  noΒ Β  person with theΒ  given name, doΒ Β Β Β  notΒ  perform
anyΒ  actionΒ Β Β Β  andΒ  returnΒ Β Β Β  false.Β Β Β Β  Likewise,Β  DOΒ Β  NOTΒ  displayΒ Β Β  anyΒ  warningΒ Β Β  messages.
DisplayΒ Β Β  allΒ  people: ThisΒ Β Β Β  functionΒ Β  shouldΒ Β Β Β  displayΒ Β Β  theΒ  names ofΒ Β  every person inΒ  theΒ Β Β Β  systemΒ Β Β Β  oneΒ  perΒ  line. If
theΒ  there areΒ  noΒ Β  oneΒ  inΒ Β  theΒ  system,Β Β Β  display–EMPTY–.
Person name1
Person name2
Β¬βˆ‘ Β¬βˆ‘ Β¬βˆ‘
PARTΒ  B:
InΒ Β  thisΒ  part, youΒ  willΒ  extendΒ Β Β Β  theΒ  PhoneBook system youΒ  designedΒ Β  inΒ Β  PartΒ  A.Β Β  ForΒ  this,Β Β Β Β  first,Β Β Β Β  youΒ  areΒ  supposed
toΒ Β  implementΒ  theΒ  Phone and Person classes whoseΒ Β Β  interfaces are givenΒ Β  below.Β Β Β Β  DoΒ Β  notΒ  deleteΒ Β Β Β  orΒ Β  modify
anyΒ  partΒ  ofΒ Β  theΒ  given dataΒ  membersΒ Β Β  orΒ Β  memberΒ Β Β Β  functions. However,Β Β  youΒ  mayΒ  defineΒ Β Β Β  additional functionsΒ  and
dataΒ  members,Β Β  ifΒ Β  necessary.
#ifndef __PHONE_H
#define __PHONE_H
using namespace std;
class Phone{
public:
Phone();
Phone( const int areaCode, const int number );
int getAreaCode();
int getNumber();
private:
int areaCode;
int number;
};
#endif
4
#ifndef __PERSON_H
#define __PERSON_H
#include <string>
using namespace std;
class Person{
public:
Person( const string name = “” );
~Person();
Person( const Person& personToCopy );
void operator=( const Person &right );
string getName();
bool addPhone( const int areaCode, const int number );
bool removePhone( const int areaCode, const int number );
void displayPhoneNumbers();
private:
struct PhoneNode {
Phone p;
PhoneNode* next;
};
PhoneNode *head;
string name;
PhoneNode* findPhone( const int areaCode, const int number );
};
#endif
PutΒ  theΒ  Person classΒ Β Β  inΒ  aΒ Β  file calledΒ Β Β  Person.h andΒ Β Β  itsΒ  implementationΒ  inΒ  Person.cpp, andΒ  putΒ  the
Phone class inΒ Β  aΒ Β Β  fileΒ  calledΒ Β Β Β  Phone.h and itsΒ  implementationΒ Β  inΒ Β  Phone.cpp. ImplementΒ Β  allΒ  theΒ Β Β Β  functions
given inΒ Β  theΒ  headerΒ Β Β Β  files above.Β Β Β Β  YouΒ  mustΒ  keepΒ  theΒ  phones ofΒ  aΒ Β Β  person inΒ  aΒ Β Β  linked-listΒ  ofΒ Β Β Β Β Β Β  PhoneNodes whose
headΒ  pointerΒ Β  isΒ  PhoneNode *head. InΒ Β  this classΒ Β Β Β  definition ofΒ  aΒ Β  Person,Β Β Β  youΒ  also seeΒ  theΒ  prototype ofΒ  a
privateΒ Β Β  functionΒ Β  calledΒ Β Β Β  findPhone. YouΒ  mayΒ  wantΒ  toΒ Β  implementΒ  suchΒ  anΒ Β  auxiliaryΒ  functionΒ Β Β Β  andΒ  useΒ  itΒ Β  inΒ Β  your
addΒ  andΒ  removeΒ Β Β Β  functions. ThisΒ  functionΒ Β  takes theΒ  areaΒ  codeΒ  andΒ  theΒ  numberΒ Β Β Β  ofΒ Β  aΒ Β Β Β  phone,Β Β Β Β  thenΒ  searchesΒ Β  itΒ Β  in
theΒ  linkedΒ Β Β  list ofΒ  phones,Β Β  andΒ  finallyΒ Β Β  returnsΒ Β Β  aΒ Β  pointerΒ Β  toΒ  theΒ  PhoneNode thatΒ Β Β Β  containsΒ  that phone ifΒ  the
phone existsΒ Β Β Β  inΒ  theΒ  system.Β Β  Otherwise, itΒ  returnsΒ Β  NULL.Β Β Β Β  This auxiliary functionΒ  mayΒ  help youΒ  writeΒ Β Β Β  more
concise codes.Β Β  However,Β Β  ifΒ Β  youΒ  doΒ Β  notΒ  wantΒ  toΒ Β  useΒ  it,Β  justΒ  defineΒ Β Β Β  anΒ Β  empty functionΒ Β Β Β  (with noΒ Β  statements).
HereΒ  isΒ Β  someΒ  information about theΒ  functionsΒ  toΒ Β  beΒ Β  implemented inΒ Β  theΒ  Person class:
AddΒ  aΒ Β Β  phone number: ThisΒ Β Β Β  functionΒ Β  addsΒ  aΒ Β Β  phone numberΒ Β Β Β  toΒ Β  theΒ  person.Β Β Β  TheΒ  areaΒ Β Β Β  code andΒ Β  number of
theΒ  phone areΒ  specified asΒ Β  parameters.Β Β Β Β  InΒ Β  this system,Β Β  phone numbersΒ Β  areΒ  uniquelyΒ Β Β Β  identified byΒ  the
areaΒ  code andΒ  theΒ  numberΒ Β Β  together. Thus,Β Β Β Β  ifΒ  theΒ  user attemptsΒ  toΒ  enter aΒ Β  phone thatΒ  existsΒ Β Β Β  forΒ  that
person,Β Β Β  displayΒ Β Β  aΒ Β Β  warningΒ Β Β  messageΒ Β Β  andΒ  returnΒ Β Β Β  false.Β Β Β Β  Otherwise, returnΒ Β Β Β  true.
RemoveΒ Β Β Β  aΒ Β Β  phone number: ThisΒ Β Β Β  functionΒ Β  removesΒ Β Β  aΒ Β Β  phone fromΒ  theΒ  personβ€šΓ„Γ΄s record.Β Β Β  TheΒ Β Β Β  areaΒ  codeΒ  and
theΒ  numberΒ Β Β Β  ofΒ Β  theΒ  phone toΒ Β  beΒ Β  deletedΒ Β Β  areΒ  specifiedΒ  asΒ Β  parameters. IfΒ Β  there isΒ Β  noΒ Β Β Β  phone number inΒ  the
listΒ  ofΒ Β  theΒ  person,Β Β Β  displayΒ Β Β  aΒ Β Β  warningΒ Β Β  messageΒ Β Β  andΒ  returnΒ Β Β Β  false.Β Β Β Β  Otherwise,Β Β Β Β  returnΒ Β Β Β  true.
DisplayΒ Β Β  phone numbers: ThisΒ Β  functionΒ  listsΒ Β Β Β  allΒ  phone numbers already addedΒ Β Β Β  toΒ  theΒ Β Β Β  personβ€šΓ„Γ΄s record.
TheΒ  outputΒ Β Β Β  shouldΒ Β Β Β  beΒ Β  inΒ Β  theΒ  followingΒ  format.Β Β Β  IfΒ Β  theΒ  there areΒ  noΒ Β  phone numbers ofΒ Β  theΒ  person,Β Β Β  display
–EMPTY–.
Phone number: Area Code1, Number1
5
Phone number: Area Code2, Number2
Β¬βˆ‘ Β¬βˆ‘Β¬βˆ‘
Then, extendΒ Β Β Β  theΒ  Person classΒ Β Β Β  from PartΒ  A,Β Β  suchΒ  that nowΒ  itΒ Β  keeps theΒ  phone numbersΒ Β Β  ofΒ Β Β Β  aΒ Β Β  person.Β Β Β  These
phones must beΒ Β  keptΒ  inΒ Β  anotherΒ Β Β  LINKED-LIST.Β Β Β Β  NoteΒ  thatΒ  theΒ  numberΒ Β Β Β  ofΒ Β  phonesΒ Β Β Β  forΒ  aΒ Β Β Β  person isΒ  notΒ  known in
advance.Β Β  Here, doΒ Β  notΒ  forgetΒ Β Β Β  toΒ Β  implementΒ  theΒ  constructor,Β Β Β Β  destructor, andΒ  copyΒ Β Β Β  constructor ofΒ Β  thisΒ  Person
class asΒ  well asΒ  doΒ  notΒ  forgetΒ Β Β  toΒ  overloadΒ  itsΒ  assignment operator. Otherwise, youΒ  mayΒ  encounter some
unexpected run-timeΒ  errors.Β Β  This time,Β Β Β Β  theΒ  interface ofΒ  theΒ  Person classΒ Β Β  must beΒ  writtenΒ Β Β  inΒ  aΒ Β  file called
Person.h, andΒ Β Β  itsΒ  implementationΒ Β  mustΒ  beΒ Β  writtenΒ Β Β  inΒ Β  aΒ Β Β  fileΒ  calledΒ Β Β Β  Person.cpp.
After extendingΒ  theΒ  Person class,Β Β Β  nowΒ  workΒ  onΒ Β  theΒ  implementationΒ Β  ofΒ Β  theΒ  followingΒ Β Β Β  functionalitiesΒ  thatΒ  your
PhoneBook system shouldΒ Β Β Β  support:
1.Β Β  AddΒ  aΒ Β Β  person
2.Β Β  RemoveΒ Β Β Β  aΒ Β Β  person
3.Β Β  DisplayΒ Β Β  allΒ  people
4.Β Β  AddΒ  aΒ Β Β  phone toΒ Β  aΒ Β Β  person
5.Β Β  RemoveΒ Β Β Β  aΒ Β Β  phone from aΒ Β Β  person
6.Β Β  ShowΒ  detailedΒ Β  information about aΒ Β Β  particular person
7.Β Β  FindΒ  theΒ  people associated withΒ  aΒ Β Β  specificΒ Β  areaΒ  code
AddΒ  aΒ Β  person: ThisΒ Β Β  functionΒ  adds aΒ Β  person to theΒ  system.Β Β  TheΒ  name ofΒ  theΒ  person isΒ Β  specified asΒ  a
parameter. InΒ  this function, theΒ  phone list isΒ  notΒ  specified; theΒ  phone(s)Β  will beΒ  addedΒ Β Β Β  later.Β Β Β  InΒ  this
system,Β Β Β  person namesΒ Β Β Β  areΒ  uniqueΒ Β Β Β  (case insensitive).Β Β Β  Thus, ifΒ Β  theΒ  userΒ  attemptsΒ Β  toΒ Β Β Β  enter aΒ Β Β  person with an
alreadyΒ Β Β  registered name,Β Β Β Β  displayΒ Β  aΒ Β  warningΒ Β  messageΒ Β  andΒ  returnΒ Β Β  false.Β Β Β  Otherwise, ifΒ  theΒ  personΒ Β Β  is
correctlyΒ  added toΒ Β  theΒ  system,Β Β Β  thenΒ  returnΒ Β Β Β  true. ThisΒ  functionΒ Β  isΒ Β  veryΒ  similarΒ Β Β  toΒ Β Β Β  whatΒ  youΒ  willΒ  implement
inΒ Β  PartΒ  A.Β Β  ButΒ  now,Β  forΒ  PartΒ  B,Β Β  youΒ  willΒ  needΒ  toΒ Β  createΒ Β Β Β  anΒ Β  empty phone list forΒ  theΒ Β Β Β  person when youΒ  add
itΒ Β  toΒ Β  theΒ  system.
RemoveΒ Β Β Β  aΒ Β Β  person: ThisΒ Β Β Β  functionΒ Β  removesΒ Β Β  aΒ Β Β  person from theΒ  system.Β Β Β  TheΒ  nameΒ  ofΒ Β Β Β  thisΒ  personΒ Β Β Β  isΒ Β  specified
asΒ Β  aΒ Β Β  parameter. IfΒ Β  there isΒ Β  noΒ Β  personΒ Β Β Β  withΒ  theΒ  given name, displayΒ Β Β  aΒ Β Β  warningΒ Β Β Β  messageΒ Β Β  andΒ  returnΒ Β Β Β  false.
Otherwise, ifΒ Β  theΒ  personΒ Β Β Β  isΒ Β  correctlyΒ  added toΒ Β  theΒ  system,Β Β Β  thenΒ  returnΒ Β Β Β  true. ThisΒ Β Β Β  functionΒ Β  isΒ Β  veryΒ  similar
toΒ Β  whatΒ  youΒ  willΒ  implementΒ  inΒ Β  PartΒ  A.Β Β  ButΒ  now,Β  forΒ  PartΒ  B,Β Β  youΒ  willΒ  needΒ  toΒ Β  removeΒ Β Β Β  itsΒ  phone list when
youΒ  removeΒ Β Β Β  theΒ  personΒ Β Β Β  fromΒ  theΒ  system.
DisplayΒ Β Β  allΒ  people: ThisΒ Β Β Β  functionΒ Β  lists allΒ  peopleΒ Β Β Β  alreadyΒ Β Β  registered inΒ Β  theΒ  system along withΒ  theΒ  number
ofΒ Β  phone numbersΒ Β Β  registered forΒ  them. TheΒ  outputΒ Β Β Β  shouldΒ Β Β Β  beΒ Β  inΒ Β  theΒ  followingΒ  format.Β Β Β Β  IfΒ Β  theΒ  there areΒ  no
people inΒ  theΒ  system,Β Β Β  displayΒ Β Β  –EMPTY–.
Person name1, number of phones name1 has
Person name2, number of phones name2 has
Β¬βˆ‘ Β¬βˆ‘ Β¬βˆ‘
AddΒ  aΒ Β Β  phone toΒ Β  a person: ThisΒ Β  functionΒ Β  addsΒ  aΒ Β Β  phone toΒ Β  theΒ  phone list ofΒ Β  aΒ Β Β  person.Β Β Β Β  TheΒ  personΒ Β Β Β  nameΒ  for
which theΒ  phone isΒ Β  submittedΒ  to, is specified asΒ Β  aΒ Β Β  parameter. AlsoΒ  theΒ  areaΒ  codeΒ  andΒ  theΒ Β Β Β  phone number
areΒ  parameters toΒ Β  thisΒ  function.Β  InΒ Β  thisΒ  function,Β  youΒ  shouldΒ Β Β Β  takeΒ  careΒ  ofΒ Β  theΒ  followingΒ Β Β Β  issues:
β€šΓ³Γ¨ IfΒ Β Β Β  theΒ  personΒ Β Β Β  withΒ  theΒ  specifiedΒ  nameΒ  doesΒ  notΒ  exist inΒ Β  theΒ  system,Β Β Β  displayΒ Β Β  aΒ Β Β Β  warningΒ Β Β  messageΒ Β Β  and
returnΒ Β Β Β  false.
β€šΓ³Γ¨ AllΒ Β Β  phone numbers are uniqueΒ Β Β Β  withinΒ Β Β Β  theΒ  sameΒ  phone listΒ  ofΒ Β  aΒ Β Β  person.Β Β Β  Thus, ifΒ Β  theΒ Β Β Β  userΒ  attempts
toΒ Β  addΒ  anΒ  existingΒ  phone toΒ  aΒ Β  person,Β Β  displayΒ Β  aΒ Β  warningΒ Β  messageΒ Β  andΒ  returnΒ Β Β Β  false.Β Β Β  However,
differentΒ  peopleΒ Β Β Β  can have theΒ Β Β  same phoneΒ Β Β Β  number.Β Β  NoteΒ  that aΒ Β  phone numberΒ Β Β Β  canΒ  beΒ Β Β Β  shared
among peopleΒ Β Β Β  (i.e.,Β Β Β Β  homeΒ  phone number).
IfΒ Β  aboveΒ Β Β Β  mentioned criteriaΒ  areΒ  met, then theΒ  phoneΒ Β Β Β  canΒ  beΒ  addedΒ Β Β Β  toΒ  theΒ  personΒ Β Β Β  andΒ  this function
returnsΒ Β Β  true.
6
RemoveΒ Β Β Β  aΒ Β Β  phone from a person: ThisΒ Β  functionΒ  removesΒ Β Β  aΒ Β Β  phone from theΒ  phone listΒ  ofΒ Β  aΒ Β Β Β  person.Β Β Β  The
personΒ Β Β Β  nameΒ  forΒ  which theΒ  phone isΒ Β  toΒ Β  beΒ Β  deleted,Β Β  andΒ  theΒ  areaΒ  codeΒ  andΒ  theΒ  numberΒ Β Β Β  toΒ Β  beΒ Β  deletedΒ Β Β  are
specified as parameters.Β Β Β  IfΒ Β  there isΒ Β  noΒ Β  personΒ Β Β Β  withΒ  theΒ  specifiedΒ  nameΒ  orΒ Β  ifΒ Β  theΒ Β Β Β  specified phoneΒ  number
(area codeΒ  +Β Β Β  number) is notΒ  inΒ Β  theΒ  phone list ofΒ Β  theΒ  specified person,Β Β Β  displayΒ Β Β  aΒ Β Β Β  warningΒ Β Β  messageΒ Β Β  and
returnΒ Β Β Β  false.Β Β Β Β  Otherwise, returnΒ Β Β Β  true.
ShowΒ  detailedΒ  informationΒ Β Β Β  aboutΒ Β Β Β  aΒ Β  particular person: ThisΒ Β Β Β  functionΒ  displaysΒ  all phone numbersΒ Β Β  ofΒ Β  a
personΒ Β Β Β  whose nameΒ  isΒ Β  specified asΒ Β  aΒ Β Β  parameter. TheΒ  outputΒ Β Β Β  shouldΒ Β Β  beΒ  inΒ Β  theΒ  followingΒ  format.Β Β  IfΒ Β  the
personΒ Β Β Β  withΒ  theΒ  specifiedΒ  nameΒ  doesΒ  notΒ  exist inΒ Β  theΒ  system,Β Β Β  displayΒ Β Β  –EMPTY– afterΒ  theΒ Β Β Β  first line.
Person name
Phone number: Area Code1, Number1
Phone number: Area Code2, Number2
Phone number: Area Code3, Number3
FindΒ  theΒ  peopleΒ Β Β Β  associated withΒ  aΒ Β Β  specificΒ  area code: This functionΒ  listsΒ Β Β Β  allΒ  theΒ Β Β Β  people whoseΒ Β Β Β  phone
number listsΒ Β Β Β  containΒ Β  aΒ Β  phoneΒ Β Β Β  with theΒ  specified area code.Β Β Β Β  TheΒ  outputΒ Β Β  shouldΒ Β Β Β  beΒ  inΒ  theΒ  following
format. FirstΒ Β Β  write theΒ  queriedΒ Β Β  areaΒ  code. Then, list theΒ  names ofΒ Β  theΒ  peopleΒ Β Β Β  whoΒ  have aΒ Β Β Β  phone withΒ  the
specifiedΒ  areaΒ  code along with theΒ Β  phone number(s)Β  ofΒ Β  thatΒ  person with thatΒ  areaΒ  codeΒ  only. IfΒ Β  aΒ Β Β Β  person
doesΒ  notΒ  haveΒ  aΒ Β Β  phone numberΒ Β Β Β  withΒ  thatΒ  areaΒ  codeΒ  doΒ Β  notΒ  listΒ  him/her at all.
Area Code1
Person name (for the 1st person)
Phone number: Area Code1, Number1
Phone number: Area Code1, Number2
Person name (for the 2nd person)
Phone number: Area Code1, Number3
Phone number: Area Code1, Number4
Β¬βˆ‘ Β¬βˆ‘ Β¬βˆ‘
IfΒ Β  nobodyΒ Β Β Β  inΒ Β  yourΒ  systemΒ Β Β Β  has a phone numberΒ Β Β Β  withΒ  that areaΒ  code, write –EMPTY– afterΒ  theΒ  area
codeΒ  thatΒ  isΒ Β  being searchedΒ Β  for.
Area Code1
–EMPTY–
Below isΒ Β  theΒ  requiredΒ Β  publicΒ Β Β Β  partΒ  ofΒ Β  theΒ  PhoneBook classΒ  thatΒ  youΒ  mustΒ  write inΒ Β  PartΒ  BΒ Β Β Β  ofΒ Β  thisΒ  assignment.
TheΒ  name ofΒ  theΒ  classΒ Β Β Β  must beΒ  PhoneBook. TheΒ  interface forΒ  theΒ  classΒ Β Β Β  must beΒ  writtenΒ Β Β  inΒ  aΒ Β  file called
PhoneBook.h andΒ  itsΒ  implementationΒ  must beΒ  writtenΒ Β  inΒ  aΒ Β  file calledΒ Β Β  PhoneBook.cpp.Β  YourΒ  class
definition shouldΒ Β Β  containΒ Β  theΒ  following memberΒ Β Β  functions andΒ  theΒ  specified data members.Β Β Β Β  However,Β  this
time, ifΒ Β  necessary, youΒ  mayΒ  alsoΒ  defineΒ Β Β Β  additional publicΒ Β Β Β  andΒ  privateΒ Β Β  memberΒ Β Β Β  functionsΒ Β Β Β  andΒ  dataΒ  membersΒ Β Β  in
yourΒ  class.Β Β Β Β  YouΒ  canΒ  alsoΒ  defineΒ Β Β Β  additional classesΒ Β Β  inΒ Β  yourΒ  solution.Β  OnΒ Β  theΒ  otherΒ Β Β Β  hand, youΒ  areΒ  notΒ  allowedΒ Β Β  to
deleteΒ Β Β Β  anyΒ  ofΒ Β  theΒ  given functionsΒ  orΒ Β  modifyΒ Β Β Β  theΒ  prototypeΒ  ofΒ Β  anyΒ  ofΒ Β  these givenΒ Β Β Β  functions.
7
WhatΒ  toΒ Β  submitΒ Β Β Β  forΒ  PartΒ  B?
YouΒ  shouldΒ Β Β  putΒ  your Phone.h, Phone.cpp, Person.h, Person.cpp, PhoneBook.h, and
PhoneBook.cpp (andΒ Β Β  additional .hΒ Β  andΒ  .cpp files ifΒ Β  youΒ  implementΒ  additional classes)Β Β  intoΒ  aΒ Β Β Β  folderΒ Β Β Β  andΒ  zip
theΒ  folder.Β Β Β  InΒ Β  thisΒ  zipΒ  file, there shouldΒ Β Β Β  notΒ  beΒ Β  anyΒ  fileΒ  containing theΒ  mainΒ  function.Β Β Β Β  TheΒ  nameΒ  ofΒ Β  thisΒ  zipΒ  file
shouldΒ Β Β Β  be:Β  PartB_secX_Firstname_Lastname_StudentID.zipΒ  where XΒ Β Β  isΒ Β  yourΒ  sectionΒ Β Β  number.Β Β Β Β  ThenΒ  followΒ Β Β  the
steps thatΒ  willΒ  beΒ Β  explainedΒ  atΒ Β  theΒ  endΒ  ofΒ Β  thisΒ  documentΒ Β  forΒ  theΒ  submission ofΒ Β  PartΒ  B.
NOTES ABOUT IMPLEMENTATIONΒ Β  (forΒ  bothΒ  PartΒ  AΒ Β Β  andΒ  PartΒ  B):
1. YouΒ Β Β Β  MUST useΒ  LINKED-LISTs in your implementation. YouΒ  will getΒ  noΒ  pointsΒ Β Β  ifΒ  you useΒ Β Β Β  automatically
allocatedΒ  arrays,Β Β Β  dynamically allocatedΒ  arrays,Β Β Β  orΒ Β  anyΒ  other dataΒ  structures suchΒ  asΒ Β Β Β  vector/array from
theΒ  standardΒ Β  library.
2. Do notΒ  deleteΒ Β Β Β  orΒ Β  modifyΒ Β Β Β  anyΒ  partΒ  ofΒ Β  theΒ  given dataΒ  membersΒ Β Β  orΒ Β  memberΒ Β Β Β  functionsΒ  forΒ  theΒ  given classes.
YouΒ  areΒ  notΒ  allowedΒ Β Β  toΒ Β  defineΒ Β Β Β  additional functionsΒ  andΒ  dataΒ  membersΒ Β Β  forΒ  classesΒ Β Β  inΒ Β Β Β  PartΒ  A,Β Β  butΒ  youΒ  mayΒ  do
soΒ Β  forΒ  PartΒ  B,Β Β  ifΒ Β  necessary.
3. YouΒ Β Β Β  AREΒ  NOTΒ  ALLOWEDΒ Β Β  toΒ Β  useΒ  anyΒ  globalΒ Β Β Β  variablesΒ  orΒ Β  anyΒ  globalΒ Β Β Β  functions.
4. YourΒ Β Β  codeΒ  mustΒ  notΒ  haveΒ  anyΒ  memoryΒ Β Β Β  leaks forΒ  PartΒ  B.Β Β  YouΒ  willΒ  loseΒ  pointsΒ Β Β Β  ifΒ Β  youΒ Β Β Β  haveΒ  memoryΒ Β Β Β  leaks in
yourΒ  programΒ Β Β  evenΒ  thoughΒ Β Β Β  theΒ  outputsΒ Β Β  ofΒ Β  theΒ  operations areΒ  correct.
5. YourΒ Β Β  implementationΒ Β  shouldΒ Β Β Β  considerΒ Β  allΒ  names asΒ Β  caseΒ  insensitive.
#ifndef __PHONEBOOK_H
#define __PHONEBOOK_H
#include <string>
using namespace std;
#include “Person.h”
class PhoneBook {
public:
PhoneBook();
~PhoneBook();
PhoneBook( const PhoneBook& systemToCopy );
void operator=( const PhoneBook &right );
bool addPerson( string name );
bool removePerson( string name );
bool addPhone( string personName, int areaCode, int number );
bool removePhone( string personName, int areaCode, int number );
void displayPerson( string name );
void displayAreaCode( int areaCode );
void displayPeople();
private:
struct Node {
Person t;
Node* next;
};
Node *head;
int numberOfPeople;
Node* findPerson( string name );
};
#endif

 

  • PhoneBook-Project-master-kzk67q.zip