Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ currently I am stuck with the rules to validate input data. please help out. much appreciated. Part I- DriverLicense.h (50 points) DriverLicense class

image text in transcribedimage text in transcribed

in c++ currently I am stuck with the rules to validate input data. please help out. much appreciated.

Part I- DriverLicense.h (50 points) DriverLicense class has the following data members: ID, firstName, lastName, address, expDate, issueDate, dateOfBirth, heightFeet, heightlnches, licenseType, eyeColor, gender While heightFeet and heightInches are integer values, the rest of the data members are all strings. Step1. Create a file named DriverLicense.h and add include guards. Define your class with public and private blocks. Step2. Under the private block define your data members. Initialize the integer values to 0 . Step3. Define setter functions under the public block for each and every data member with the following validation rules. Rule1. ID must be 9 digits long and must use only digit characters. Rule2. Date data members(expDate, issueDate, dateOfBirth) will have the following string format MM/DD/YYYY. Month values must be between 1 and 12 . Day values must be less than or equal to the maximum number of days in a month. Since there are multiple date values write a private function that checks the format and returns a bool value. Then call that function from the setter of a date data member. For example: void setDate0fBirth(std: : string dob) \{ // check whether it s a valid date format if (checkDate(dob)) date0fBirth = dob; \} else throw std::invalid_argument("Invalid date."); If the function returns false, throw an invalid_argument exception. Use this exception for all the other validation purposes. Rule3. HeightFeet and HeightInches should be positive values. Rule4. LicenseType can be one of the 8 string values. You can define a static const array to hold these values: static const std::array types ={ "A", "B", "C", "D", "DJ","E", "M", "MJ" }; Rule 5. Gender can be one of 3 values: " M ", " F ", " X " If these rules are not satisfied, then throw an invalid_argument exception. Step 4. Define getter methods for each data member under the public block. These functions will only return the data member values. Step 5. Add the following toString() function to create and return a string representation of all of the data member values. Step 6. Define a default constructor with no parameters and a constructor that takes parameters for all data members. In the body of that constructor call the setter functions to set the parameter values: DriverLicense(std::string iid, std::string fName, std: string LName, std::string addr, std::string iDate, std::string eDate, std:string dob, int feet, int inches, std::string lType, std::string eColor, std::string gen) \{ //call all setter functions setID(iid) ; // \} Step 7. Test your program with the attached main.cpp file. Submit only DriverLicense.h Sample output: Invalid ID: 9 digits required. Invalid ID: only digits allowed. Invalid date. Invalid date. Invalid license type. Gender is invalid. Use M F or X

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

Recommended Textbook for

More Books

Students also viewed these Databases questions