Question
bool read(); Assuming that the names are not longer than 70 characters, this function will attempt to read all the values from the console in
bool read();
Assuming that the names are not longer than 70 characters, this function will attempt to read all the values from the console in local (function scope) variables first and if successful, they will be validated and then stored in the object.
The function will return true if the values are stored in the object and false otherwise.
Follow these steps to write this function: Create an array of 71 characters for the name and temporary variables for other attributes of the class.
The function will first call cleanUp() to deallocate possible previous data allocation and reads the values into local function scope variables as follows:
- Prompt "Card holder name: "
- using cin.getline() read 71 characters into a local name cstring.
- if cin has not failed prompt "Credit card number: "
- read the credit card number into a local unsigned long long variable.
- if cin has not failed prompt "Card Verification Value (CVV): "
- read the CVV number into a local short integer
- if cin has not failed prompt "Expiry month and year (MM/YY): "
- reads the expiry month and year into short integer variables in one line by cin.ignore()ing the delimiter between them, you don't need to make sure it is a '/' character. This separator can be any non-digit character to separate the month and year values.
- check the status of cin to set the object:
- if cin has not failed, call the set(name, no, cvv, mon,year) function to set the object
- if cin has failed, clear() the cin.
- in any case, flush the keyboard using ignore
- at end return false if object isEmpty() and return true if not.
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