Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <iomanip>
- #include "Publication.h"
- using namespace std;
- // classes
- class Books : public Publication {
- public:
- int pages;
- int sales, sales1, sales2;
- void ReadData(string inputA, double inputB, int inputC, int sales, int sales1, int sales2) {
- this->title = inputA;
- this->price = inputB;
- this->pages = inputC;
- this->sales = sales;
- this->sales1 = sales1;
- this->sales2 = sales2;
- }
- void DisplayData() {
- cout << "Title: " << title << endl << "Price: " << price << endl << "Length: " << pages << endl;
- }
- };
- class Tapes : public Publication {
- public:
- double timeInMin;
- int sales, sales1, sales2;
- void ReadData(string inputA, double inputB, double inputC, int sales, int sales1, int sales2) {
- this->title = inputA;
- this->price = inputB;
- this->timeInMin = inputC;
- this->sales = sales;
- this->sales1 = sales1;
- this->sales2 = sales2;
- }
- void DisplayData() {
- cout << "Title: " << title << endl << "Price: " << price << endl << "Length: " << timeInMin << endl;
- }
- };
- //variables
- int temp, temp1, temp2;
- int RBuffer;
- string buffer_Title;
- double buffer_Price;
- int buffer_length;
- double buffer_lengthDouble;
- void main() {
- vector<Books> vectorBooks;
- vector<Tapes> vectorTapes;
- for (int i = 0; i < 3; i++) {
- Books *BooksPtr = new Books;
- BooksPtr->ReadData("Gone With The Wind", 59.99, 566, 0, 0, 0);
- BooksPtr->DisplayData();
- vectorBooks.push_back(*BooksPtr);
- }
- for (int i = 0; i < 2; i++) {
- Tapes *TapesPtr = new Tapes;
- TapesPtr->ReadData("Beethoven", 99.99, 60, 0, 0, 0);
- TapesPtr->DisplayData();
- vectorTapes.push_back(*TapesPtr);
- }
- for (int i = 0; i < vectorBooks.size(); i++) {
- cout << "What are the sales for month 1 of the book " << vectorBooks[i].title << "?" << endl;
- cin >> temp;
- cout << "What are the sales for month 2 of the book " << vectorBooks[i].title << "?" << endl;
- cin >> temp1;
- cout << "What are the sales for month 3 of the book " << vectorBooks[i].title << "?" << endl;
- cin >> temp2;
- vectorBooks[i].sales = temp;
- vectorBooks[i].sales1 = temp1;
- vectorBooks[i].sales2 = temp2;
- }
- for (int i = 0; i < vectorTapes.size(); i++) {
- cout << "What are the sales for month 1 of the tape " << vectorTapes[i].title << "?" << endl;
- cin >> temp;
- cout << "What are the sales for month 2 of the tape " << vectorTapes[i].title << "?" << endl;
- cin >> temp1;
- cout << "What are the sales for month 3 of the tape " << vectorTapes[i].title << "?" << endl;
- cin >> temp2;
- vectorTapes[i].sales = temp;
- vectorTapes[i].sales1 = temp1;
- vectorTapes[i].sales2 = temp2;
- }
- for (Tapes c : vectorTapes) {
- cout << "Sales for tape " << c.title << endl;
- cout << setw(10) << left << "Month 1" << setw(10) << left << "Month 2" << setw(10) << left << "Month 3" << endl;
- cout << setw(10) << left << c.sales << setw(10) << left << c.sales1 << setw(10) << left << c.sales2 << endl << endl;
- }
- for (Books c : vectorBooks) {
- cout << "Sales for book " << c.title << endl;
- cout << setw(10) << left << "Month 1" << setw(10) << left << "Month 2" << setw(10) << left << "Month 3" << endl;
- cout << setw(10) << left << c.sales << setw(10) << left << c.sales1 << setw(10) << left << c.sales2 << endl << endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment