Guest User

Untitled

a guest
Feb 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. // definicja_klasy.cpp : Defines the entry point for the console application.
  2. //
  3. #include "StdAfx.h"
  4. #include <string>
  5. #include <time.h>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. class book
  11. {
  12. private:
  13.     string title;
  14.     string aName;
  15.     string aSurname;
  16.     string publisher;
  17.     int pages;
  18.     int L_page;
  19.     bool OPENED;
  20.  
  21. public:
  22.     /*KONSTRUKTORY*/
  23.     book(){
  24.                 title       = "nieznany";
  25.                 aName       = "nieznany";
  26.                 aSurname    = "nieznany";
  27.                 publisher   = "nieznane";
  28.                 pages       =   0;
  29.                 OPENED      =   0;
  30.                 L_page      =   0;
  31.                     }
  32.  
  33.     book(string f_title, string f_aName, string f_aSurname, string f_publisher, int f_pages){
  34.                
  35.                 title       = f_title;
  36.                 aName       = f_aName;
  37.                 aSurname    = f_aSurname;
  38.                 publisher   = f_publisher;
  39.                 pages       = f_pages;
  40.                     }
  41.     /*---------------------------------------------------------*/
  42.     /*METODY*/
  43.     void show_book()
  44.     {
  45.         cout << "Tytul ksiazki: " << title << endl;
  46.         cout << "Autor: "         << aName << " " << aSurname << endl;
  47.         cout << "wydawnictwo: "   << publisher    << endl;
  48.         cout << "ilosc stron: "   << pages        << endl;
  49.  
  50.         is_opened();
  51.     }
  52.    
  53.    
  54.     void is_opened()
  55.     {
  56.         if(OPENED==0)
  57.             cout << "ksiazka jest zamknieta!" << endl;
  58.  
  59.         else if(OPENED==1)
  60.             cout << "ksiazka otwarta na stronie: " << L_page << " i " << L_page+1 << endl;
  61.     }
  62.    
  63.     void open_close_book(){
  64.         if(OPENED==0)
  65.         {
  66.             OPENED=1;
  67.             srand( time(NULL) );
  68.             L_page = rand() % pages;           
  69.                 }
  70.         else if(OPENED==1)
  71.         {
  72.             OPENED=0;
  73.             L_page = 1;
  74.                 }
  75.             }
  76. };
  77.  
  78. /*WIEM, ZE TO SA FUNKCJE INLINE, I WIEM JAK DZIALAJA! NIE CZEPIAJ SIE! :D */
  79.  
  80.  
  81. int main()
  82. {
  83.     int x;
  84.  
  85.  
  86.     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ą*/
  87.  
  88.  
  89.     cin >> x;
  90.     return 0;
  91. }
Add Comment
Please, Sign In to add comment