Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include<fstream>
- using namespace std;
- enum class Rodzaj { STRATEGICZNA, PRZYGODOWA, AKCJI, HORROR, MOBILNA, STRZELANKA };
- struct Gra
- {
- string tytul;
- string wydawca;
- int rokWydania;
- Rodzaj rodzaj;
- void drukuj();
- };
- void Gra::drukuj() {
- std::cout << this->tytul << "" << this->wydawca << " " << this->rokWydania << endl;
- }
- Gra stworzGre(string tyt, string wyd, int rok, Rodzaj r) {
- return Gra{tyt,wyd,rok,r};
- };
- int main()
- {
- Gra* czteryGry = new Gra[4];
- czteryGry[0] = stworzGre("Wiedzmin", "CDPR", 2010, Rodzaj::HORROR);
- czteryGry[1] = stworzGre("Gothic", "Belial", 2002, Rodzaj::HORROR);
- czteryGry[2] = stworzGre("Hearthstone", "Blizzard", 2011, Rodzaj::HORROR);
- czteryGry[3] = stworzGre("TMNF", "Nadeo", 1995, Rodzaj::HORROR);
- for (int i = 0; i < 4; i++) {
- czteryGry[i].drukuj();
- }
- ofstream myfile;
- myfile.open("Gra.txt");
- myfile << czteryGry[0].tytul << ",\n" << czteryGry[0].wydawca << ",\n" << czteryGry[0].rokWydania << "\n";
- myfile.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement