#include <iostream>
#include <string>
#include <fstream>
using namespace std;

/*
*Коротко о программе: программа создана для подсчёта проданных книг(по количеству,имени, цене) 
*/




class MainProgramCore {
public:
	ofstream fout;
	void getNameAndPrice() {
		int price = 0;
		string name = "";
		fout.open("soldbooks.txt", ios_base::app);
		cout << "Hello. I'am your own helper! Type name then press enter and type price!";
		cin >> name >> price;
		fout << name << ":" << price << "$\n";
		fout.close();
	}
	void countAmount() {
		char *str = new char[1024];
		int amount = 0;
		ifstream iout("soldbooks.txt");
		while (!iout.eof())
		{
			iout.getline(str, 1024, '\n');
			amount++;
		}
		cout << "You sold: " << amount-1 << " books! \n ";
		delete str;
	}
	void countTotalEarned() {
	
	}
};

// Объявление переменных
void mainViarables();
int price, number, amount;
string name, answer;

int main() {
	MainProgramCore objMainProgramCore;
	objMainProgramCore.countAmount();
	objMainProgramCore.countTotalEarned();
	cout << "Hello! If you sold any book, type Y. If you didn't, just ignore this message! : ";
	cin >> answer;
	if ((answer == "Y") || (answer == "y")) {
		cout << "Ok! How much books did you sell? Type number: ";
		cin >> number;
		for (int i = 0; i < number; i++) {
			objMainProgramCore.getNameAndPrice();
		}
		system("pause");
		return 0;

	}
}



