Code:
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
class Address{
private:
string street, city, state, zip, country;
public:///////////////std::string Address::street2
Address();
Address(string, string, string, string, string);
Address(const Address &);
bool compare(Address &);
bool merge (Address &);
void setStreet(string);
void setCity(string);
void setState(string);
void setZip(string);
void setCountry(string);
string getStreet()const;
string getCity()const;
string getState()const;
string getZip()const;
string getCountry()const;
void print()const;
void read();
};
Address::Address(){
street="";
city="";
state="";
zip="";
country="";
}
Address::Address(string st, string c, string s, string z, string ct){
street=st;
city=c;
state=s;
zip=z;
country=ct;
}
Address::Address(const Address & copy){
street=copy.street;
//street2=copy.street2;
city=copy.city;
state=copy.state;
zip=copy.zip;
country=copy.country;
}
void Address:: setStreet(string st){
street=st;
}
void Address::setCity(string c){
city=c;
}
void Address::setState(string s){
state=s;
}
void Address::setZip(string z){
zip=z;
}
void Address::setCountry(string ct){
country=ct;
}
string Address::getStreet()const{
return street;
}
string Address::getCity()const{
return city;
}
string Address::getState()const{
return state;
}
string Address::getZip()const{
return zip;
}
string Address::getCountry()const{
return country;
}/////////////////////////////////////////////////////////////////////////////
bool Address::compare(Address & b){
if (street==b.street)
{cout<<"same street"<<endl;}
if(state==b.state)
{cout<<"same state"<<endl;}
if(city==b.city)
{cout<<"samae city"<<endl;}
if(zip==b.zip)
{cout<<"same code"<<endl;}
if(country==b.country)
{cout<<"same country"<<endl;}
return true;
return false;
}
void Address::print()const{
cout<<"Your Current Street:"<<street<<endl;
cout<<"Your Current City:"<<city<<endl;
cout<<"Your Current State:"<<state<<endl;
cout<<"Your Current Code:"<<zip<<endl;
cout<<"Your Current Country:"<<country<<endl;
}
void Address::read(){
cout<<"Enter Your Current Street:"<<endl;
getline(cin,street);
cout<<"Enter Your Current City:"<<endl;
getline(cin,city);
cout<<"Enter Your Current State:"<<endl;
getline(cin,state);
cout<<"Enter Your Current Code:"<<endl;
getline(cin,zip);
cout<<"Enter Your Current Country:"<<endl;
getline(cin,country);
}
int main(){
Address location1("1001 Kalapoosa St","Tuscaloosa","Al","35401","USA"),location2;/*("90","Northport","Al","35476","USA")*/
Address copy("1002 10th Ave","Tuscaloosa","Al","35406","USA");
location2.setStreet("298");
location2.setCity("Talapoosa");
location2.setState("GA");
location2.setZip("35478");
location2.setCountry("USA");
cout<<endl;
cout<<"location1"<<endl;
location1.print();
cout<<endl;
cout<<endl;
cout<<"location2"<<endl;
location2.print();
cout<<endl;
Address location3(copy);
cout<<endl;
cout<<"location3"<<endl;
location3.print();
cout<<endl;
///////////////////
/*
Address b.location(location3);
cout<<endl;
cout<<"new address"<<endl;
b.print();///////////////////
*/
string a, b, c;
if (a.compare(b))
cout<<"This is truely a pair"<<endl;
else
cout<<"false, not a pair"<<endl;
location3.setStreet("1");
//location3.setStreet2("O st");
location3.setCity("Tuscaloosa");
location3.setState("TX");
location3.setZip("34576");
location3.setCountry("UK");
/*
cout<<endl;
cout<<"new location 2"<<endl;
location2.compareState(location3);
location2.print();
cout<<endl;
*/
//c.getState(b);
location2.read();
cout<<endl;
cout<<"location 2 new info changed to:"<<endl;
location2.print();
system ("PAUSE");
return 0;
}
Comment