1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
class personalInfo
{
private:
string name;
string adress;
int age;
int phoneNumber;
public:
void setName(string);
void setAdress(string);
void setAge(int);
void setNumber(int);
string getName() const;
string getAdress() const;
int getAge() const;
int getNumber() const;
};
#include<iostream>
#include <string>
#include"hwlab4headerfile.h"
using namespace std;
void personalInfo::setName(string n)
{
name=n;
}
void personalInfo::setAdress(string adr)
{
adress=adr;
}
void personalInfo::setAge(int ag)
{
age=ag;
}
void personalInfo::setNumber(int num)
{
phoneNumber=num;
}
string personalInfo::getName() const
{
return name;
}
string personalInfo::getAdress() const
{
return adress;
}
int personalInfo::getAge() const
{
return age;
}
int personalInfo::getNumber() const
{
return phoneNumber;
}
#include<iostream>
#include <string>
#include"hwlab4headerfile.h"
using namespace std;
int main()
{
personalInfo myInfo; // instance of my information for personalInfo class
personalInfo friendInfo; // instant of friend's information for personalInfo class
personalInfo familyInfo; // instance of family's information for personal info class
string na; // variable for name
string addr; // variable for address
int a; // variable for age
int nu; // variable for phone number
//get information from user
cout << "This program will ask you for your information, your friend's information\n";
cout << "and a family member's information."<< endl;
cout << "Please enter your name" << endl;
getline(cin,na);
cout << "Please enter your address" << endl;
getline(cin,addr);
cout << "Please enter your age" << endl;
cin >> a;
cout << "Please enter your phone number" << endl;
cin >> nu;
cout << "Your information has been saved, now you will enter your friend's information." << endl;
/*//store information from user into appropriate functions for name, address, age and phone number for their own information
myInfo.setName(na);
myInfo.setAdress(addr);
myInfo.setAge(a);
myInfo.setNumber(nu);
cout << "Your information has been saved, now you will enter your friend's information." << endl;
*/
cout << "Please enter your friend's name" << endl;
getline(cin, na);
cout << "Please enter your friend's address" << endl;
getline(cin, addr);
cout << "Please enter your friend's age" << endl;
cin >> a;
cout << "Please enter your friend's phone number" << endl;
cin >> nu;
cout << "Your information has been saved, now you will enter a family member's information." << endl;
/*//store information from user into appropriate functions for name, address, age and phone number for friend
friendInfo.setName(na);
friendInfo.setAdress(addr);
friendInfo.setAge(a);
friendInfo.setNumber(nu);
cout << "Your information has been saved, now you will enter a family member's information." << endl;
*/
cout << "Please enter your family member's name" << endl;
getline(cin,na);
cout << "Please enter your family member's address" << endl;
getline(cin, addr);
cout << "Please enter your family member's age" << endl;
cin >> a;
cout << "Please enter your family member's phone number" << endl;
cin >> nu;
cout << "Your family member's information has been saved" << endl;
//store information from user into appropriate functions for name, address, age and phone number for their own information
myInfo.setName(na);
myInfo.setAdress(addr);
myInfo.setAge(a);
myInfo.setNumber(nu);
//store information from user into appropriate functions for name, address, age and phone number for friend
friendInfo.setName(na);
friendInfo.setAdress(addr);
friendInfo.setAge(a);
friendInfo.setNumber(nu);
//store information from user into appropriate functions for name, address, age and phone number for family member
familyInfo.setName(na);
familyInfo.setAdress(addr);
familyInfo.setAge(a);
familyInfo.setNumber(nu);
//Show the user their own information
cout << "Here is your information: " << endl;
cout << "Name: " << myInfo.getName() << endl;
cout << "Address: " << myInfo.getAdress() << endl;
cout << "Age: " << myInfo.getAge() << endl;
cout << "Phone Number: " << myInfo.getNumber() << endl;
// show the user their friend's information
cout << "Here is your information: " << endl;
cout << "Name: " << friendInfo.getName() << endl;
cout << "Address: " << friendInfo.getAdress() << endl;
cout << "Age: " << friendInfo.getAge() << endl;
cout << "Phone Number: " << friendInfo.getNumber() << endl;
// show the user their family member's information
cout << "Here is your information: " << endl;
cout << "Name: " << familyInfo.getName() << endl;
cout << "Address: " << familyInfo.getAdress() << endl;
cout << "Age: " << familyInfo.getAge() << endl;
cout << "Phone Number: " << familyInfo.getNumber() << endl;
system("Pause");
return 0;
}
|