Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 1.29 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Book  {
  6.     private:
  7.         int currentPage;
  8.         int totalPages;
  9.     public:
  10.         Book(int total, int current);
  11.         int getCurrentPage() {return currentPage;};
  12.         void setPage(int page){currentPage = page;};
  13. };
  14.  
  15. int main()
  16. {
  17.     int currentBooks = 0;
  18.     cout << "How many books are you reading?" << endl;
  19.     cin >> currentBooks;
  20.     int totalP[currentBooks], currentP[currentBooks], temp1, temp2;
  21.     if (currentBooks > 0)   {
  22.         for (int i = 1; i < (currentBooks + 1); i++)    {
  23.                 cout << "How many pages in book " << i << "?" << endl;
  24.                 cin >> totalP[i];
  25.                 cout << "What page are you on currently?" << endl;
  26.                 cin >> currentP[i];
  27.                 temp1 = totalP[i];
  28.                 temp2 = currentP[i];
  29.                 Book instance(temp1,temp2);
  30.         }
  31.     }
  32.     else   {
  33.         cout << "Awwh, reading is fun!" << endl;
  34.         return 0;
  35.     }
  36.  
  37.     return 0;
  38. }
  39.     Book::Book(int total, int current)    {
  40.         totalPages = total;
  41.         if (total < current)    {
  42.             cout << "The current page cannot be greater than the total amount of pages" << endl;
  43.         }
  44.         else    {
  45.             currentPage = current;
  46.         }
  47.     }