Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Object Oriented Programming Design a class based on a modified Customer Structure Create class methods (Setters and Getters) that load the data values. The Setter

Object Oriented Programming

Design a class based on a modified Customer Structure

Create class methods (Setters and Getters) that load the data values. The Setter methods will validate the input data based on the criteria below and load the data into the class if valid.

For character arrays, the data must be within the specified data size.

For zipCode, the number must be between 0 and 99999.

City and State need to be stored in UpperCase.

Write a program that will allow me to enter data for the class and create and call a method that displays the data for the class.

During the input process, pass the input data to the setter method and confirm that the data entered is valid based on the class method return value. If not valid,prompt for me to re-enter the data until it does pass the class method's validation. I only need to enter the data for 1 instance of the class. The best way to do this is for the setter methods to return bool instead of void. If the data is valid, return true. Otherwise return false.

There is no need to loop for multiple instances of the object. Do not use cin statements inside the class method definitions.

const int NAME_SIZE = 20; const int STREET_SIZE = 30; const int CITY_SIZE = 20; const int STATE_CODE_SIZE = 3;

struct 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;
};

Hints: The const variables need to be defined outside of the class definition.

All access to the data in the class must use public methods that you define. DO NOT DIRECTLY ACCESS the customer data items.

The class level input methods should return a boolean to confirm the data was loaded and passed any size or data ranges. The customerNumber setter can return void.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Students also viewed these Databases questions

Question

What is the purpose of plot() and varImp() functions?

Answered: 1 week ago