Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Write C++ program follow below For this assignment, modify your Contact class to use a declare/define/use approach. Modify your Contact class so that now the

Write C++ program follow below

For this assignment, modify your Contact class to use a declare/define/use approach. Modify your Contact class so that now the address of the Contact is of class type Address and not a string. As an added challenge, I will not provide you with the .cpp file for this Address class, rather, only the .o file, to which you can link your program for testing purposes and .h file so that you would know what my Address class supports. Write a driver program that does the following:

1. Create a partially filled array of Contacts with capacity equal to 10.

2. Ask the user to input up to 10 Contacts (It may be less. The user should have the ability to stop inputting Contacts whenever he wishes).

3. Create a Menu in your main program with 3 options: search, display all, and exit. a) Provide a function in your main program that will be able to search for a particular Contact in your array of Contacts. Search must be based on the name. The function would return an index. You can call this function in your main program if the user selects option search from the menu to output information about this Contact in your main program. b) Provide a function in your main program that will allow you to print ALL Contacts in the array. Call this function if the user selects display all option from the menu. c) Exit the program if the user selects exit option from the menu. Note that you do not need to know the implementation of the Address class. In order to compile your program and link it to my Address class you will need to do the following: 1. Before you begin writing any program, make a copy of the Address.h and Address.o files into your directory. Do this by typing the following (note the . at the end): cp ~alayev/cs211/spring2019/hw3/Address.h . cp ~alayev/cs211/spring2019/hw3/Address.o . 2. Write your program. 3. Compile your program: Note you will have 3 files to compile and link: main.cpp Contact.cpp and Address.o.

below is Address.h

// Address.h

/** * Declaration of class Address. It is used to store and retrieve * information on Address such as home number, street, apt#, city, * state, and zip. * * Author: Yosef Alayev */

#ifndef ADDRESS_H

#define ADDRESS_H

#include using namespace std;

class Address

{

private:

string home;

string street;

string apt;

string city;

string state;

string zip;

public:

// Default constructor

// Initializes all variable to empty string

Address();

// Accessor method for the home instance variable string getHome() const; // Accessor method for the street instance variable string getStreet() const;

// Accessor method that returns apartment number // if it is an apartment building, or "none" if // it is a private house. string getApt() const;

// Accessor method for the city instance variable string getCity() const; // Accessor method for the state instance variable string getState() const;

// Accessor method for the zip instance variable string getZip() const; // Method that prints Address to console void output() const;

// Method that solicits the information

// Apartment will be set to "none" if it is a private house

// If it is an Apartment Building, method will solicit

// info about apartment

void input();

};

#endif

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started