Question
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
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 setDateOfBirth(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.****
In C++, to clarify. A for or while loop is needed for validation. Currently to validate the following string format: MM/DD/YYYY I have the code: "for(size_t i = 0; i < dob.size(); i++) { if (i == 2 or i ==5) { if(dob[i] == '/') return true; //check if dob[i] is '/ else return false; }"
and this is where I am having a little trouble
Step 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