Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using C++ In this case, start directly using three files: a header, the code of the class, and the main program. The goal is to
Using C++
In this case, start directly using three files: a header, the code of the class, and the main program. The goal is to program a class that models a contact in a phone application Step 1. create and code your class (Contact.h, Contact.cpp, main.cpp). Start with the header file to define your class. a) Define private data members: contactName, phoneNumber, and also add a data member favoriteBook to your contact. The type of this data member is a Book as created in PART I. You will need to include the Book.h header in your Contact.h header so that the type Book is defined. b) Define a constructor which accepts three parameters for data members. None of the parameters can be empty. c) Define setters and getters for all data members. Step 2. Write the implementation of all the member functions in Contact.cpp Step 3. Test your new class in main.cpp. Accept all the parameters from the user. Create a Book object and set it up with values given by the user. Then create a Contact object and set it up with values given by the user. Print using the following format Sample output: Enter contact name: John Doe Enter phone number: 555-55-55 Enter author for favorite book: J.R.R Tolkien Enter title for favorite book: Lord of the Rings Enter year for favorite book: 1954 Enter publisher for favorite book: George Allen Ltd. Enter city for publisher: London Enter state for publisher: UK Contact: John Doe Phone: 555-55-55 Favorite Book : J.R.R Tolkien (1954). Lord of the Rings. London, UK: George Allen Ltd.. In this case, start directly using three files: a header, the code of the class, and the main program. The goal is to program a class that models a contact in a phone application Step 1. create and code your class (Contact.h, Contact.cpp, main.cpp). Start with the header file to define your class. a) Define private data members: contactName, phoneNumber, and also add a data member favoriteBook to your contact. The type of this data member is a Book as created in PART I. You will need to include the Book.h header in your Contact.h header so that the type Book is defined. b) Define a constructor which accepts three parameters for data members. None of the parameters can be empty. c) Define setters and getters for all data members. Step 2. Write the implementation of all the member functions in Contact.cpp Step 3. Test your new class in main.cpp. Accept all the parameters from the user. Create a Book object and set it up with values given by the user. Then create a Contact object and set it up with values given by the user. Print using the following format Sample output: Enter contact name: John Doe Enter phone number: 555-55-55 Enter author for favorite book: J.R.R Tolkien Enter title for favorite book: Lord of the Rings Enter year for favorite book: 1954 Enter publisher for favorite book: George Allen Ltd. Enter city for publisher: London Enter state for publisher: UK Contact: John Doe Phone: 555-55-55 Favorite Book : J.R.R Tolkien (1954). Lord of the Rings. London, UK: George Allen LtdStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started