#include <string>
#include <iostream>
using namespace std;
class Beer{
private:
string name;
int supply;
public:
Beer(string b_name, int b_supply) {
name = b_name;
supply = b_supply;
}
void printBeer() {
cout << "Type: " << name << endl;
cout << "Amount: " << supply << endl;
cout << "-------------------------\n";
}
const Beer & operator=(const Beer &rBeer) {
name = rBeer.name;
supply = rBeer.supply;
return *this;
}
bool operator==(const Beer &rBeer) const {
return (name == rBeer.name && supply == rBeer.supply);
}
bool operator!=(const Beer &rBeer) const {
return (name != rBeer.name || supply != rBeer.supply);
}
};
int main() {
Beer myBeer("Bud Light", 6);
Beer frndBeer("Budweiser", 5);
myBeer.printBeer();
frndBeer.printBeer();
if(myBeer == frndBeer)
cout << "\nBeer is the same." << endl;
else
cout << "\nBeer is different." << endl;
myBeer = frndBeer;
if(myBeer != frndBeer)
cout << "Copy constructor has failed." << endl;
else
cout << "Copy constructor worked, you both have equal beer\n\n";
myBeer.printBeer();
frndBeer.printBeer();
return 0;
}