Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // definicja_klasy.cpp : Defines the entry point for the console application.
- //
- #include "StdAfx.h"
- #include <string>
- #include <time.h>
- #include <iostream>
- using namespace std;
- class book
- {
- private:
- string title;
- string aName;
- string aSurname;
- string publisher;
- int pages;
- int L_page;
- bool OPENED;
- public:
- /*KONSTRUKTORY*/
- book(){
- title = "nieznany";
- aName = "nieznany";
- aSurname = "nieznany";
- publisher = "nieznane";
- pages = 0;
- OPENED = 0;
- L_page = 0;
- }
- book(string f_title, string f_aName, string f_aSurname, string f_publisher, int f_pages){
- title = f_title;
- aName = f_aName;
- aSurname = f_aSurname;
- publisher = f_publisher;
- pages = f_pages;
- }
- /*---------------------------------------------------------*/
- /*METODY*/
- void show_book()
- {
- cout << "Tytul ksiazki: " << title << endl;
- cout << "Autor: " << aName << " " << aSurname << endl;
- cout << "wydawnictwo: " << publisher << endl;
- cout << "ilosc stron: " << pages << endl;
- is_opened();
- }
- void is_opened()
- {
- if(OPENED==0)
- cout << "ksiazka jest zamknieta!" << endl;
- else if(OPENED==1)
- cout << "ksiazka otwarta na stronie: " << L_page << " i " << L_page+1 << endl;
- }
- void open_close_book(){
- if(OPENED==0)
- {
- OPENED=1;
- srand( time(NULL) );
- L_page = rand() % pages;
- }
- else if(OPENED==1)
- {
- OPENED=0;
- L_page = 1;
- }
- }
- };
- /*WIEM, ZE TO SA FUNKCJE INLINE, I WIEM JAK DZIALAJA! NIE CZEPIAJ SIE! :D */
- int main()
- {
- int x;
- book ksiazka1 /* domyslny konstruktor */, ksiazka2( ARG1, ARG2, ARG3, ...); /* i tu jak chce mu zapodac jakies stringi jako argumenty, np "uwaga czarny parasol", "adam", "bahdaj" ,... to mi płacze, a w deklaracji występują*/
- cin >> x;
- return 0;
- }
Add Comment
Please, Sign In to add comment