
Untitled
By: a guest on
May 6th, 2012 | syntax:
None | size: 1.29 KB | hits: 14 | expires: Never
#include <iostream>
using namespace std;
class Book {
private:
int currentPage;
int totalPages;
public:
Book(int total, int current);
int getCurrentPage() {return currentPage;};
void setPage(int page){currentPage = page;};
};
int main()
{
int currentBooks = 0;
cout << "How many books are you reading?" << endl;
cin >> currentBooks;
int totalP[currentBooks], currentP[currentBooks], temp1, temp2;
if (currentBooks > 0) {
for (int i = 1; i < (currentBooks + 1); i++) {
cout << "How many pages in book " << i << "?" << endl;
cin >> totalP[i];
cout << "What page are you on currently?" << endl;
cin >> currentP[i];
temp1 = totalP[i];
temp2 = currentP[i];
Book instance(temp1,temp2);
}
}
else {
cout << "Awwh, reading is fun!" << endl;
return 0;
}
return 0;
}
Book::Book(int total, int current) {
totalPages = total;
if (total < current) {
cout << "The current page cannot be greater than the total amount of pages" << endl;
}
else {
currentPage = current;
}
}