Question: Create a project in C++ program with the three classes below, Address, Customer, and Book. Then write a test class with a main() method that

Create a project in C++ program with the three classes below, Address, Customer, and Book. Then write a test class with a main() method that instantiates two addresses, two customers and two books.

Address

(Classes with upper case letters, attributes start with lower case and use Camelcase naming convention)

Put method prototypes in Address.h and the method implementation in Address.cpp

Constructors:

Address() //default empty constructor

Address(string street, string city, string state, string zip) //overloaded

Private Attributes:

string street

string city

string state

string zip

Public Methods

get/set for each attribute, example:

void setStreet (string street) {

this-> street = street;

}

string getStreet() {

return street;

}

print

Customer

Put method prototypes in Customer.h and the method implementation in Customer.cpp

Constructors:

Customer() //default empty constructor

Customer(string custID, string firstName, string lastName, Address address)

Private Attributes:

string custID

string firstName

string lastName

string address

Public Methods

get/set for each attribute, example:

void setAddress (Address address) {

this-> address = address;

}

string getAddress() {

return address;

}

print

Book

Put method prototypes in Book.h and the method implementation in Book.cpp

Constructors:

Book() //default empty constructor

Book(string ISBN, string author, string title, string address)

Private Attributes:

string ISBN

string author

string title

string price

Public Methods

get/set for each attribute, example:

void setPrice (double price) {

this-> price = price;

}

double getPrice() {

return price;

}

In the set method of the ISBN attribute, validate that the number is either 9 or 13 digits (even though a passing a string, validate the length and that it contains only digits), if invalid set the ISBN to zero.

In the set method of the price, validate that price is between $1 and $200, if invalid set the price to zero.

Print

Test Class

Write a test class with a main() method that instantiates two addresses, two customers, and two books. Instantiate one of each with the default (blank constructors) and use setters to set the information. Instantiate one of each using the overloaded constructor.

Print out both customers and both books.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!