Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- //books: title, autor, next edition, ISBN number, date of publication, edition
- class Books {
- private:
- string book_name;
- string autor;
- int next_edition;
- int isbn_number;
- int circulation;
- public:
- 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;
- }
- };
- 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.
- month = 0, day = 0, year = 0;
- }
- Date::Date(int Month, int Day, int Year)
- {
- month = Month;
- day = Day;
- 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 Bookseller {
- 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;
- }
- };
- int main()
- {
- int Month, Day, Year;
- string monthName[] = { "January", "February", "March",
- "April", "May", "June", "July",
- "August", "September", "October",
- "November", "December" };
- cout << "Please enter a month (between 1 - 12) " << endl;
- cin >> Month;
- cout << "Please enter a day (between 1 - 31) " << endl;
- cin >> Day;
- cout << "Please enter a year (between 1950 - 2020) " << endl;
- cin >> Year;
- Date newDate(Month, Day, Year);
- newDate.showDate1();
- newDate.showDate2();
- cin.get();
- cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement