// Attached: HW_9f-1
// ===========================================================
// File: HW_9f-1
// ===========================================================
// Programmer: Elaine Torrez
// Class: CMPR 121
// ===========================================================
#include <iostream>
#include <string>
using namespace std;
class Dog
{
private:
string name;
float weight;
int age;
public:
Dog(string dogName, float dogWeight, int dogAge)
{
name = dogName;
weight = dogWeight;
age = dogAge;
}
~Dog()
{
}
void displayDog()
{
cout << "NAME: " << name << endl;
cout << "WEIGHT: " << weight << " pounds" << endl;
cout << "AGE: " << age << " years old." << endl;
}
bool operator >= (int years)
{
return age >= years;
}
bool operator < (Dog rightSide)
{
return weight < rightSide.weight;
}
bool operator == (Dog rightSide)
{
return name == rightSide.name;
}
friend ostream& operator << (ostream& out, Dog dogObject)
{
out << "NAME: " << dogObject.name << endl;
out << "WEIGHT: " << dogObject.weight << " pounds" << endl;
out << "AGE: " << dogObject.age << " years old.";
return out;
}
};
int main()
{
Dog myDog("Spot", 5.5, 3);
Dog yourDog("Jack", 4.5, 3);
if (myDog >= 2)
cout << "The dog is at least 2 years old.\n\n";
else
cout << "The dog is less than 2 years old.\n\n";
if (yourDog < myDog)
cout << "Your dog weighs less than my dog.\n\n";
else
cout << "Your dog does not weigh less than my dog.\n\n";
if (myDog == yourDog)
cout << "They have the same name.\n\n";
else
cout << "They do not have the same name.\n\n";
cout << yourDog << endl;
return 0;
}