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;
- //books: title, autor, next edition, ISBN number, date of publication, edition
- 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;
- }
- //cout << "Entet date DD/MM/YY: ";
- //int Month, Day, Year;
- //cin >> Day >> Month >> Year;
- //cout << endl;
- //Date newDate(Day, Month, Year);
- //newDate.showDate();
- //cin.get();
- //cout << endl;
- class Books : public Date
- {
- private:
- string book_name;
- string autor;
- int next_edition;
- int isbn_number;
- int circulation;
- public:
- Books() {
- cout << "Enter book's name: ";
- cin >> book_name;
- cout << endl;
- cout << "Enter autor name: ";
- cin >> autor;
- cout << endl;
- cout << endl;
- cout << "Enter next edition: ";
- cin >> next_edition;
- cout << endl;
- cout << "Enter ISBN number: ";
- cin >> isbn_number;
- cout << endl;
- 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;
- cout << "Enter circulation: ";
- cin >> autor;
- cout << endl;
- }
- void setBookName(string book)
- {
- book_name = book;
- }
- string getBookName()
- {
- return book_name;
- }
- void setAutor(string autor_name)
- {
- autor = autor_name;
- }
- string getAutor()
- {
- return autor;
- }
- 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 Books :public Date
- {
- private:
- string book_name;
- string autor;
- int next_edition;
- int isbn_number;
- int circulation;
- public:
- Books();
- Books(string, string, int, int, int);
- ~Books() { }
- void setBookName(string);
- void setAutorName(string);
- void setNextEdition(int);
- void setIsbnNumber(int);
- void setBookCirculation(int);
- };
- Books::Books() {
- book_name = "";
- autor = "";
- next_edition = 0;
- isbn_number = 0;
- circulation = 0;
- }
- Books::Books(string bookName, string autorName, int nextEditon, int isbnNumber, int bookCirculation)
- {
- book_name = bookName;
- autor = autorName;
- next_edition = nextEditon;
- isbn_number = isbnNumber;
- circulation = bookCirculation;
- }
- void Books::setBookName(string bookName) {
- cout << "Enter book's name: " << endl;
- cin >> bookName;
- cout << endl;
- }
- void Books::setAutorName(string autor)
- {
- cout << "Enter autor name: " << endl;
- cin >> autor;
- cout << endl;
- }
- void Books::setNextEdition(int edition)
- {
- cout << "Enter next edition: " << endl;
- cin >> edition;
- cout << endl;
- }
- void Books::setIsbnNumber(int isbn_num)
- {
- cout << "Enter ISBN number: " << endl;
- cin >> isbn_num;
- cout << endl;
- }
- void Books::setBookCirculation(int circ)
- {
- cout << "Enter circulation: " << endl;
- cin >> circ;
- cout << endl;
- }
- */
- class Bookseller : public Books
- {
- private:
- string name_bookseller;
- string address_bookseller;
- int phone_bookseller;
- public:
- 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;
- }
- };
- /*
- class Bookseller :public Books
- {
- private:
- string name_bookseller;
- string address_bookseller;
- int phone_bookseller;
- public:
- Bookseller();
- Bookseller(string name, string address, int phone);
- ~Bookseller () { }
- void setBookseller(string);
- void setAddress(string);
- void setPhone(int);
- };
- Bookseller::Bookseller() {
- name_bookseller = "";
- address_bookseller= "";
- phone_bookseller = 0;
- }
- Bookseller::Bookseller(string name, string address, int phone)
- {
- name_bookseller = name;
- address_bookseller = address;
- phone_bookseller = phone;
- }
- void Bookseller::setBookseller(string name)
- {
- cout << "Enter bookseller name: " << endl;
- cin >> name;
- cout << endl;
- }
- void Bookseller::setAddress(string address)
- {
- cout << "Enter address: " << endl;
- cin >> address;
- cout << endl;
- }
- void Bookseller::setPhone(int phone)
- {
- cout << "Enter next edition: " << endl;
- cin >> phone;
- cout << endl;
- }
- */
- int main()
- {
- string end;
- Books b;
- Bookseller bs;
- ofstream BookInfo;
- // Write to the file
- BookInfo.open("BookInfo.txt");
- if (end == "end") {
- return 0;
- }
- else {
- b.setBookName("" "");
- b.setAutorName("" "");
- b.setNextEdition(0);
- b.setIsbnNumber(0);
- /*
- 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;
- */
- 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