#include "student.h" #define NDEBUG #include using namespace std; //////////////////////////////////////////////////////////////// // Initialize variables in the class to false // Parameters: // -None // // Pre: -None // // Post: variables in class have a default value // // Returns: none // // Called by: none // // Calls: None ///////////////////////////////////////////////////////////////// student::student() { //Constructor emailAvailable = false; //Does the student have an e-mail address ? nameAvailable = false; //Did student provide name ? phoneAvailable = false; address1Available = false; //Is the address listed ? address2Available = false; cityAvailable = false; //Was city listed ? State listed ? Zipcode? stateAvailable = false; zipcodeAvailable = false; miscAvailable = false; //Is there any miscellaneous information resetPrev = false; //Was the information reset previously ? zipcode = 0; phoneNumber1 =0; phoneNumber2 =0; areaCode = 0; } student::~student() { //Destructor } //////////////////////////////////////////////////////////////// // Returns the boolean value dependent upon the value set to the variable "emailAvailable" // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: boolean value true/false // // Called by: printEmail(); printItem(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::emailPresent() const { //Return based on validity of statement return emailAvailable; } //////////////////////////////////////////////////////////////// // Returns the boolean value dependent upon the value set to the variable "nameAvailable" // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: boolean value true/false // // Called by: printEmail(); printItem(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::namePresent() const { //Return based on validity of statement return nameAvailable; } //////////////////////////////////////////////////////////////// // Returns the boolean value dependent upon the value set to the variable "address1Available" // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: boolean value true/false // // Called by: printEmail(); printItem(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::address1Present() const { //Return based on validity of statement return address1Available; } //////////////////////////////////////////////////////////////// // Returns the boolean value dependent upon the value set to the variable "address2Available" // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: boolean value true/false // // Called by: printEmail(); printItem(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::address2Present() const { return address2Available; } //////////////////////////////////////////////////////////////// // Returns the boolean value dependent upon the value set to the variable "cityPresent" // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: boolean value true/false // // Called by: printEmail(); printItem(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::cityPresent() const { //Return based on validity of statement return cityAvailable; } //////////////////////////////////////////////////////////////// // Returns the boolean value dependent upon the value set to the variable "stateAvailable" // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: boolean value true/false // // Called by: printEmail(); printItem(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::statePresent() const { return stateAvailable; //Return based on validity of statement } //////////////////////////////////////////////////////////////// // Returns the boolean value dependent upon the value set to the variable "zipcodeAvailable" // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: boolean value true/false // // Called by: printEmail(); printItem(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::zipcodePresent() const { //Return based on validity of statement return zipcodeAvailable; } //////////////////////////////////////////////////////////////// // Returns the boolean value dependent upon the value set to the variable "miscAvailable" // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: boolean value true/false // // Called by: printEmail(); printItem(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::miscPresent() const { //Return based on validity of statement return miscAvailable; } //////////////////////////////////////////////////////////////// // Sets parameter value to string variable Name // // Parameters: // -string ----- the students name // // Pre: -None // // Post: The variable Name is set to students name // // Returns: True // // Called by: initalizeItem(); deleteEmail(); printEmail(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setName(string Name) { student::studentName = Name; return true; } //////////////////////////////////////////////////////////////// // Sets the areacode of the class. The rest of the phoen number is parsed // and stored accordingly. // // Parameters: // -ifstream& inFile ----- the students name // -unsigned int areaCode -- the area code of the student // // Pre: -None // // Post: The variable Name is set to students name // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setNumber(unsigned int areaCode, ifstream& inFile) { unsigned int phoneFirst =0; //First half of phone number unsigned int phoneSecond = 0; //Second half of phone number student::areaCode = areaCode; inFile.ignore(200, ')'); inFile>>phoneFirst; assert(phoneFirst >999); student::phoneNumber1 = phoneFirst; inFile.ignore(200, '-'); inFile>>phoneSecond; assert(phoneSecond >999); student::phoneNumber2 = phoneSecond; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to string variable e_mail // // Parameters: // -string e_mail----- the email address of the student // // Pre: -None // // Post: The variable email is set to students e-mail // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setEmail(string e_mail) { student::email = e_mail; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to string variable addyLine1. // // Parameters: // -string add1----- the first line of address // // Pre: -None // // Post: The variable addyLine1 is set to add1; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setAddyLn1(string add1) { student::addyLine1 = add1; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to string variable addyLine2. // // Parameters: // -string add2----- the second line of address // // Pre: -None // // Post: The variable addyLine2 is set to add1; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setAddyLn2(string add2) { student::addyLine2 = add2; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to string variable city. // // Parameters: // -string city----- the city information // // Pre: -None // // Post: The variable city is set to city; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setCity(string city) { student::city = city; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to string variable state. // // Parameters: // -string state----- the state information // // Pre: -None // // Post: The variable state is set to state; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setState(string state) { student::state = state; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to string variable state. // // Parameters: // -unsigned int zipCode----- the zipcode information // // Pre: -None // // Post: The variable zipcode is set to zipcode; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setZipcode(unsigned int zipCode) { zipcode = zipCode; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to string variable state. // // Parameters: // -string other2----- the miscellaneous information // // Pre: -None // // Post: The variable other is set to other2; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setOther(string other2) { student::other = other2; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to bool variable emailAvailable // // Parameters: // -bool result----- the zipcode information // // Pre: -None // // Post: The variable emailAvailable is set to result; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setEmailAvailable(bool result) //Was the students e-mail deleted ? { emailAvailable = result; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to bool variable nameAvailable // // Parameters: // -bool result----- the zipcode information // // Pre: -None // // Post: The variable nameAvailable is set to result; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setNameAvailable(bool result) //Did student provide name ? { nameAvailable = result; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to bool variable address1Available // // Parameters: // -bool result----- the zipcode information // // Pre: -None // // Post: The variable address1Available is set to result; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setAddress1Available(bool result) //Is the address listed ? { address1Available = result; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to bool variable address2Available // // Parameters: // -bool result----- the zipcode information // // Pre: -None // // Post: The variable address2Available is set to result; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setAddress2Available(bool result) { address2Available = result; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to bool variable cityAvailable // // Parameters: // -bool result----- the city information // // Pre: -None // // Post: The variable cityAvailable is set to result; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setCityAvailable(bool result) //Was city listed ? State listed ? Zipcode? { cityAvailable = result; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to bool variable stateAvailable // // Parameters: // -bool result----- the state information // // Pre: -None // // Post: The variable stateAvailable is set to result; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setStateAvailable(bool result) //Is the state availble { stateAvailable = result; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to bool variable zipcodeAvailable // // Parameters: // -bool result----- the zipcode information // // Pre: -None // // Post: The variable zipcodeAvailable is set to result; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setZipcodeAvailable(bool result) //Is the zipcode available ? { zipcodeAvailable = result; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to bool variable miscAvailable // // Parameters: // -bool result----- the miscellaneous information // // Pre: -None // // Post: The variable miscAvailable is set to result; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setMiscAvailable(bool result) //Is there any miscellaneous information { miscAvailable = result; return true; } //////////////////////////////////////////////////////////////// // Sets parameter value to bool variable phoneAvailable // // Parameters: // -bool result----- the phone number information // // Pre: -None // // Post: The variable phoneAvailable is set to result; // // Returns: True // // Called by: initializeStudents(); addStudent(); // // Calls: -None // ////////////////////////////////////////////////////////////////////////////////// bool student::setPhoneNumberAvailable(bool result) { student::phoneAvailable = result; return true; } void student::resetInfo() { email = ""; //Reset e-mail address of student addyLine1=""; //Reset 1st line of address holding road the student lives on addyLine2=""; //Reset 2nd line of address holding apartment/house number city=""; //Reset city student lives in state=""; //Reset state student lives in other=""; //Reset miscellaneous information studentName=""; //Reset student's name emailAvailable = false; //Does the student have an e-mail address ? nameAvailable = false; //Did student provide name ? phoneAvailable = false; address1Available = false; //Is the address listed ? address2Available = false; cityAvailable = false; //Was city listed ? State listed ? Zipcode? stateAvailable = false; zipcodeAvailable = false; miscAvailable = false; //Is there any miscellaneous information resetPrev = true; zipcode = 0; phoneNumber1 =0; phoneNumber2 =0; areaCode = 0; } //////////////////////////////////////////////////////////////// // Returns the string variable email // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: string value email // // Called by: printEmail(); deleteEmail(); printSudents(); // // Calls: -None // /////////////////////////////////////////////////////////////////// string student::getEmail() const { return email; //Returns a string value of the e-mail address } //////////////////////////////////////////////////////////////// // Returns the string variable addyLine1 which is the address on line 1 // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: string value addyLine1 // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// string student::getAddyLine1() const { return student::addyLine1; //Returns the address on Line 1 } //////////////////////////////////////////////////////////////// // Returns the string variable addyLine1 which is the address on line 2 // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: string value addyLine2 // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// string student::getAddyLine2() const { return student::addyLine2; //Returns the address on line 2 } //////////////////////////////////////////////////////////////// // Returns the string variable city // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: string city // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// string student::getCity()const { return student::city; //Returns the city } //////////////////////////////////////////////////////////////// // Returns the string variable state // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: string state // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// string student::getState() const { return student::state; //Returns the state } //////////////////////////////////////////////////////////////// // Returns the string variable other // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: string other // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// string student::getOther() const { return student::other; //Returns miscellaneous information } //////////////////////////////////////////////////////////////// // Returns the string variable studentName // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: string studentName // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// string student::getName() const { return student::studentName; //Returns the name of the student } //////////////////////////////////////////////////////////////// // Returns the unsigned int variable phoneNumber1 // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: unsigned int variable phoneNumber1 // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// unsigned int student::getNumber1() { return phoneNumber1; //Returns the first half of the phone number } //////////////////////////////////////////////////////////////// // Returns the unsigned int variable phoneNumber12 // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: unsigned int variable phoneNumber2 // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// unsigned int student::getNumber2() { return student::phoneNumber2; //Returns the second half of the phone number } //////////////////////////////////////////////////////////////// // Returns the unsigned int variable areaCode // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: unsigned int variable areaCode // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// unsigned int student::getAreaCode() { return student::areaCode; //Returns the area code } //////////////////////////////////////////////////////////////// // Returns the unsigned int variable zipcode // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: unsigned int variable zipcode // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// unsigned int student::getZipcode() { return student::zipcode; //Returns the zipcode } //////////////////////////////////////////////////////////////// // Returns the bool variable resetPrev // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: bool variable resetPrev // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// bool student::returnReset() { return resetPrev; } //////////////////////////////////////////////////////////////// // Returns the bool variable phoneAvailable // // Parameters: // -None // // Pre: -None // // Post: -None // // Returns: bool variable phoneAvailable // // Called by: printEmail(); deleteEmail(); // // Calls: -None // /////////////////////////////////////////////////////////////////// bool student::phonePresent() const { return phoneAvailable; //Returns the whether or not a phone number was provided } void student::setReset(bool value) { resetPrev = value; }