C++ program #include #include #include using namespace std; const int NAME_SIZE = 20; const int STREET_SIZE = 30; const int CITY_SIZE = 20; const int STATE_CODE_SIZE = 3; class Customer { long...



C++ program



#include

#include

#include




using namespace std;



const int NAME_SIZE = 20;

const int STREET_SIZE = 30;

const int CITY_SIZE = 20;

const int STATE_CODE_SIZE = 3;



class Customer {



long customerNumber;

char name[NAME_SIZE];

char streetAddress_1[STREET_SIZE];

char streetAddress_2[STREET_SIZE];

char city[CITY_SIZE];

char state[STATE_CODE_SIZE];

int zipCode;



public:

void setCustomerNumber(long customerNo)

{

customerNumber = customerNo;

}



bool setName(char name[])

{

if (strlen(name) <=>

{

(this->name, name);

returntrue;

}

returnfalse;

}



bool setStreetAddress_1(char streetAddress_1[])

{

if (strlen(streetAddress_1) <=>

{

(this->streetAddress_1, streetAddress_1);

returntrue;

}

returnfalse;

}



bool setStreetAddress_2(char streetAddress_2[])

{

if (strlen(streetAddress_2) <=>

{

(this->streetAddress_2, streetAddress_2);

returntrue;

}

returnfalse;

}



bool setCity(char city[])

{



if (strlen(city) <=>

{

for (int i = 0; city[i] != '\0'; i++)

this->city[i] = toupper(city[i]);

this->city[strlen(city) - 1] = '\0';

returntrue;

}

returnfalse;

}



bool setState(char state[])

{



if (strlen(state) <=>

{

for (int i = 0; state[i] != '\0'; i++)

this->state[i] = toupper(state[i]);

this->state[strlen(state) - 1] = '\0';

returntrue;

}

returnfalse;



}



bool setZipCode(int zipCode)



{

if (zipCode > 0 && zipCode <>

{

this->zipCode = zipCode;

returntrue;

}



returnfalse;

}



void print()

{

cout < "="" customer="" number="" :="" "="">< customernumber=""><>

cout < "="" name="" :="" "="">< name=""><>

cout < "="" street="" address="" 1="" :"="">< streetaddress_1=""><>

cout < "="" street="" address="" 2="" :="" "="">< streetaddress_2=""><>

cout < "="" city="" :="" "="">< city=""><>

cout < "="" state="" :="" "="">< state=""><>

cout < "="" zipcode="" :="" "="">< zipcode=""><>



}



};



int main() {

Customer customer;

char name[100], strAdd1[100], strAdd2[100], city[100], state[100];

int zip;

srand(time(NULL));

long custNo;

cout < "="" name="" :="">



cin.getline(name, sizeof(name), '\n');



while (!customer.setName(name))



{

cout < "="" invalid="" name.\n="" name="" :="">

cin.getline(name, sizeof(name), '\n');

}

cout < "="" street="" address="" 1="" :="">

cin.getline(strAdd1, sizeof(strAdd1), '\n');

while (!customer.setStreetAddress_1(strAdd1))

{

cout < "="" invalid="" street="" address1.\n="" street="" address="" 1="" :="">

cin.getline(strAdd1, sizeof(strAdd1), '\n');

}



cout < "="" street="" address="" 2="" :="">



cin.getline(strAdd2, sizeof(strAdd2), '\n');



while (!customer.setStreetAddress_2(strAdd2))



{

cout < "="" invalid="" street="" address="" 2.\n="" street="" address="" 2="" :="">

cin.getline(strAdd2, sizeof(strAdd2), '\n');

}

cout < "="" city="" :="">

cin.getline(city, sizeof(city), '\n');

while (!customer.setCity(city))

{

cout < "="" invalid="" city.="" \n="" city:="">

cin.getline(city, sizeof(city), '\n');

}



cout < "="" state="" :="">

cin.getline(state, sizeof(state), '\n');

while (!customer.setState(state))

{

cout < "="" invalid="" state.\n="" state:="">

cin.getline(state, sizeof(state), '\n');

}



cout < "="" zip="" code="">

cin >> zip;



while (!customer.setZipCode(zip))

{

cout < "="" invalid="" zip="" code.\n="" zip="" code="">

cin >> zip;

}



custNo = (long)((rand() % 9000) + 1000);// randomly generate customer number between 1000-9999



customer.setCustomerNumber(custNo);



cout < "\n="" customer="" :="" "=""><>



customer.print();



return0;



}



Refactor Assignment 1 into 3 project related files.


Customer.h
- Class SpecificationCustomer.cpp
- Class Implementation (Methods)


TestCustomer.cpp - Your code that performs the logic from Assignment 1.


The 3 files need to be named as listed above and should compile without errors.


Deliverables are the 3 files listed above. This can be in a zip file. These files need to match the layouts as described in the chapter. Be aware the const items can be in the header file.



Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here