// Attached: Lab_10_Part2
// ===========================================================
// File: Lab_10_Part2
// ===========================================================
// Programmer: Elaine Torrez
// Class: CMPR 121
// ===========================================================

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

class Book
{
private:
    string isbn;
    int year;
    double price;
    static int bookCount;

public:
    Book()
    {
        isbn = "";
        year = 0;
        price = 0.0;
        bookCount++;
    }

    Book(string bookIsbn, int bookYear, double bookPrice)
    {
        isbn = bookIsbn;
        year = bookYear;
        price = bookPrice;
        bookCount++;
    }

    ~Book()
    {
    }

    void displayBook() const
    {
        cout << "ISBN:  " << isbn << endl;
        cout << "Year:  " << year << endl;
        cout << "Price: " << price << endl;
    }

    int getCount()
    {
        return bookCount;
    }

    bool operator>(Book book)
    {
        return price > book.price;
    }

    bool operator==(Book book)
    {
        return price == book.price;
    }

    bool operator>(double amount)
    {
        return price > amount;
    }

    double operator+(Book book)
    {
        return price + book.price;
    }

    bool operator<(int amount)
    {
        return year < amount;
    }

    friend ostream& operator<<(ostream& stream, Book& book);
    friend istream& operator>>(istream& stream, Book& book);
};

int Book::bookCount = 0;

ostream& operator<<(ostream& stream, Book& book)
{
    stream << "ISBN:  " << book.isbn << endl;
    stream << "Year:  " << book.year << endl;
    stream << "Price: " << book.price << endl;

    return stream;
}

istream& operator>>(istream& stream, Book& book)
{
    cout << "ISBN:  ";
    stream >> book.isbn;

    cout << "Year:  ";
    stream >> book.year;

    cout << "Price: ";
    stream >> book.price;

    return stream;
}

int main()
{
    Book b1("0-12345-9", 1990, 12.50);
    Book b2("0-54321-9", 2001, 7.75);
    Book b3;
    double avg;

    cout << "Here is book #1:\n";
    b1.displayBook();

    cout << "\nHere is book #2:\n";
    b2.displayBook();

    cout << "\nThere are " << b1.getCount() << " books.\n\n";

    if (b1 > b2)
        cout << "Book #1 has a higher price.\n\n";
    else
        cout << "Book #1 does not have a higher price.\n\n";

    if (b1 == b2)
        cout << "Same price.\n\n";
    else
        cout << "Not the same price.\n\n";

    if (b2 > 10.00)
        cout << "The price is more than $10.00.\n\n";
    else
        cout << "The price is not more than $10.00.\n\n";

    avg = (b1 + b2) / 2.0;

    cout << "The average book price is " << avg << ".\n\n";

    if (b1 < 2000)
        cout << "The book was published before 2000.\n\n";
    else
        cout << "The book was not published before 2000.\n\n";

    cout << b1;

    cout << "\nEnter Book #3 information.\n";
    cin >> b1;

    cout << "\nHere is what you entered for Book #3:\n";
    cout << b1;

    return 0;
}