// Attached: HW_9f-2
// ===========================================================
// File: HW_9f-2
// ===========================================================
// Programmer: Elaine Torrez
// Class: CMPR 121
// ===========================================================

#include <iostream>
#include <string>
using namespace std;

class Car
{
private:
    string model;
    int year;

    static int carCount;

public:
    Car()
    {
        model = "";
        year = 0;
        carCount++;
    }

    Car(string carModel, int carYear)
    {
        model = carModel;
        year = carYear;
        carCount++;
    }

    ~Car()
    {
    }

    void setCar(string carModel, int carYear)
    {
        model = carModel;
        year = carYear;
    }

    int getCount()
    {
        return carCount;
    }

    void displayCar()
    {
        cout << "Model:  " << model << endl;
        cout << "Year:   " << year << endl;
    }

    friend bool areSame(Car firstCar, Car secondCar);
};

int Car::carCount = 0;

bool areSame(Car firstCar, Car secondCar)
{
    return (firstCar.model == secondCar.model &&
            firstCar.year == secondCar.year);
}

int main()
{
    Car myCar;
    Car yourCar("Toyota", 2007);

    cout << "My Car" << endl;
    myCar.displayCar();
    cout << endl;

    cout << "Your Car" << endl;
    yourCar.displayCar();
    cout << endl;

    myCar.setCar("Ford", 2002);

    cout << "My Car" << endl;
    myCar.displayCar();
    cout << endl;

    if (areSame(myCar, yourCar))
        cout << "The two cars are the same model and year." << endl;
    else
        cout << "The two cars are not the same model and year." << endl;

    cout << endl;
    cout << myCar.getCount() << " cars have been declared." << endl;

    return 0;
}