#include <iostream>
#include <string>
using namespace std;
class Person{
private:
string name;
int age;
string gender;
public:
// A public default constructor that sets the data members to appropriate default values
Person(){
this->name="";
this->age=1;
this->gender="";
}
//A copy constructor
Person(Person &person){
this->name=person.name;
this->age=person.age;
this->gender=person.gender;
}
//A setPerson method that will receive and assign person data.
void setName(string name){
this->name=name;
}
void setGender(string gender){
this->gender=gender;
}
void setAge(int age){
this->age=age;
}
//getName method that returns a name with the 1st letter uppercased.
string getName(){
return this->name;
}
//A getGender method that returns "Male" or "Female" depending on the person's gender
string getGender(){
if(this->gender=="F" ||this->gender=="f"){
return "Female";
}
return "Male";
}
//A getAge method that returns a person's age
int getAge(){
return this->age;
}
};
Comments
Leave a comment