Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include<string>
- #include<sstream>
- using namespace std;
- class Date
- {
- private:
- int day;
- int month;
- int year;
- public:
- //These are consturctors
- Date();
- Date(int, int, int);
- //Destructor
- ~Date() {}
- //void do not return values
- void setDay(int);
- void setMonth(int);
- void setYear(int);
- void showDate1();
- void showDate2();
- };
- Date::Date()
- {
- //Initialize variables.
- day = 0, month = 0, year = 0;
- }
- Date::Date(int Day, int Month, int Year)
- {
- day = Day;
- month = Month;
- year = Year;
- }
- void Date::setDay(int d)
- {
- if (d < 1 && d > 31)
- cout << "The day is invalid" << endl;
- else
- day = d;
- }
- void Date::setMonth(int m)
- {
- if (m < 1 && m > 12)
- cout << "The month is invalid" << endl;
- else
- month = m;
- }
- void Date::setYear(int y)
- {
- if (y < 1950 && y > 2022)
- cout << "The year is invalid" << endl;
- else
- year = y;
- }
- void Date::showDate1()
- {
- cout << day << " /" << month << " /" << year << endl;
- }
- void Date::showDate2()
- {
- string monthName[] = { "January", "February", "March",
- "April", "May", "June", "July",
- "August", "September", "October",
- "November", "December" };
- cout << day << " " << monthName[month - 1] << " " << year << endl;
- }
- class Books : public Date
- {
- private:
- string book_name;
- string autor_name;
- int next_edition;
- int isbn_number;
- int circulation;
- public:
- Books() {
- cout << "Enter book's name: " << endl;
- cin >> book_name;
- cout<< endl;
- cout << "Enter autor name: " << endl;
- cin >> autor_name;
- cout << endl;
- cout << "Enter next edition: " << endl;
- cin >> next_edition;
- cout << endl;
- cout << "Entet date DD/MM/YY: " << endl;
- int Month, Day, Year;
- cin >> Day >> Month >> Year;
- cout << endl;
- Date newDate(Day, Month, Year);
- newDate.showDate2();
- cin.get();
- cout << endl;
- cout << "Enter circulation: " << endl;
- cin >> circulation;
- cout << endl;
- }
- void setBookName(string book)
- {
- book_name = book;
- }
- string getBookName()
- {
- return book_name;
- }
- void setAutorName(string autor)
- {
- autor_name = autor;
- }
- string getAutor()
- {
- return autor_name;
- }
- void setNextEdition(int edition)
- {
- next_edition = edition;
- }
- int getNextEdition()
- {
- return next_edition;
- }
- void setIsbnNumber(int isbn_num)
- {
- isbn_number = isbn_num;
- }
- int getIsbnNumber()
- {
- return isbn_number;
- }
- void setCirculation(int circul) {
- circulation = circul;
- }
- int getCirculation()
- {
- return circulation;
- }
- };
- class Bookseller:public Books
- {
- private:
- string name_bookseller;
- string address_bookseller;
- int phone_bookseller;
- public:
- Bookseller()
- {
- cout << "Enter bookseller name: ";
- cin >> name_bookseller;
- cout << endl;
- cout << "Enter bookseller address: ";
- cin >> address_bookseller;
- cout << endl;
- cout << "Enter bookseller phone: ";
- cin >> phone_bookseller;
- cout << endl;
- }
- void setBooksellerName(string name) {
- name_bookseller = name;
- }
- string getBooksellerName() {
- return name_bookseller;
- }
- void setBooksellerAddress(string address) {
- address_bookseller = address;
- }
- string getBooksellerAddress() {
- return address_bookseller;
- }
- void setBooksellerPhone(int phoneNumber) {
- phone_bookseller = phoneNumber;
- }
- int getBooksellerPhone() {
- return phone_bookseller;
- }
- };
- int main()
- {
- string end;
- Books b;
- Bookseller bs;
- ofstream BookInfo;
- // Write to the file
- BookInfo.open("BookInfo.txt");
- while (end != "end")
- {
- b.setBookName("" "");
- b.setAutorName("" "");
- b.setNextEdition(0);
- b.setIsbnNumber(0);
- b.setCirculation(0);
- bs.setBooksellerName("");
- bs.setBooksellerAddress("");
- bs.setBooksellerPhone(0);
- string agree;
- cin >> agree;
- if (agree == "yes") {
- cout << "This book has certificate";
- cout << "Entet date DD/MM/YY: ";
- int Month, Day, Year;
- cin >> Day >> Month >> Year;
- cout << endl;
- Date newDate(Day, Month, Year);
- newDate.showDate2();
- cin.get();
- cout << endl;
- }
- else
- {
- cout << "This book hasn't certificate";
- }
- }
- // Close the file
- BookInfo.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement