Advertisement
AntoniiaG

Untitled

Apr 26th, 2022
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. //books: title, autor, next edition, ISBN number, date of publication, edition
  6.  
  7.  
  8. class Books {
  9. private:
  10.     string book_name;
  11.     string autor;
  12.     int next_edition;
  13.     int isbn_number;
  14.     int circulation;
  15.  
  16. public:
  17.     void setBookName(string book) {
  18.         book_name = book;
  19.     }
  20.     string getBookName() {
  21.         return book_name;
  22.     }
  23.  
  24.     void setAutor(string autor_name) {
  25.         autor = autor_name;
  26.     }
  27.     string getAutor() {
  28.         return autor;
  29.     }
  30.  
  31.     void setNextEdition(int edition) {
  32.         next_edition = edition;
  33.     }
  34.     int getNextEdition() {
  35.         return next_edition;
  36.     }
  37.  
  38.     void setIsbnNumber(int isbn_num) {
  39.         isbn_number = isbn_num;
  40.     }
  41.     int getIsbnNumber() {
  42.         return isbn_number;
  43.     }
  44. };
  45.  
  46. class Date {
  47. private:
  48.     int day;
  49.     int month;
  50.     int year;
  51. public:
  52.     //These are consturctors
  53.     Date();
  54.     Date(int, int, int);
  55.     //Destructor
  56.     ~Date() {}
  57.     //void do not return values
  58.     void setDay(int);
  59.     void setMonth(int);
  60.     void setYear(int);
  61.     void showDate1();
  62.     void showDate2();
  63.  
  64. };
  65. Date::Date()
  66. {
  67.     //Initialize variables.
  68.     month = 0, day = 0, year = 0;
  69. }
  70. Date::Date(int Month, int Day, int Year)
  71. {
  72.     month = Month;
  73.     day = Day;
  74.     year = Year;
  75. }
  76. void Date::setDay(int d)
  77. {
  78.     if (d < 1 && d > 31)
  79.         cout << "The day is invalid" << endl;
  80.     else
  81.         day = d;
  82.  
  83. }
  84. void Date::setMonth(int m)
  85. {
  86.     if (m < 1 && m > 12)
  87.         cout << "The month is invalid" << endl;
  88.     else
  89.         month = m;
  90.  
  91. }
  92. void Date::setYear(int y)
  93. {
  94.     if (y < 1950 && y > 2022)
  95.         cout << "The year is invalid" << endl;
  96.     else
  97.         year = y;
  98. }
  99. void Date::showDate1()
  100. {
  101.     cout << day << " /" << month << " /" << year << endl;
  102. }
  103. void Date::showDate2()
  104. {
  105.     string monthName[] = { "January", "February", "March",
  106.         "April", "May", "June", "July",
  107.         "August", "September", "October",
  108.         "November", "December" };
  109.     cout << day << "  " << monthName[month - 1] << "  " << year << endl;
  110. }
  111.  
  112. class Bookseller {
  113. private:
  114.     string name_bookseller;
  115.     string address_bookseller;
  116.     int phone_bookseller;
  117.  
  118. public:
  119.     void setBooksellerName(string name) {
  120.         name_bookseller = name;
  121.     }
  122.     string getBooksellerName() {
  123.         return name_bookseller;
  124.     }
  125.  
  126.     void setBooksellerAddress(string address) {
  127.         address_bookseller = address;
  128.     }
  129.     string getBooksellerAddress() {
  130.         return address_bookseller;
  131.     }
  132.  
  133.     void setBooksellerPhone(int phoneNumber) {
  134.         phone_bookseller = phoneNumber;
  135.     }
  136.     int getBooksellerPhone() {
  137.         return phone_bookseller;
  138.     }
  139. };
  140.  
  141. int main()
  142. {
  143.     int Month, Day, Year;
  144.     string monthName[] = { "January", "February", "March",
  145.         "April", "May", "June", "July",
  146.         "August", "September", "October",
  147.         "November", "December" };
  148.  
  149.  
  150.     cout << "Please enter a month (between 1 - 12) " << endl;
  151.     cin >> Month;
  152.  
  153.     cout << "Please enter a day (between 1 - 31) " << endl;
  154.     cin >> Day;
  155.  
  156.     cout << "Please enter a year (between 1950 - 2020) " << endl;
  157.     cin >> Year;
  158.  
  159.  
  160.     Date newDate(Month, Day, Year);
  161.     newDate.showDate1();
  162.     newDate.showDate2();
  163.  
  164.     cin.get();
  165.     cin.get();
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement