-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
82 lines (65 loc) · 1.27 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <string>
using namespace std;
class bibliothiki{
public:
bibliothiki(); //constructor
~bibliothiki(); //destructor
void place_book(biblia bibl);
biblia take_book(int number);
void print() const;
private:
biblia b[10];
}
struct biblia{
string title;
string name;
int isbn;
}
int main(int argc, char const *argv[])
{
int K1,K2, NMax;
// NMax = atoi(argv[1]);
// K1 = atoi(argv[2]);
// K2 = atoi(argv[3]);
bibliothiki bibl(NMax); //na dimioyrgei mia bibliothiki
biblia *b = new biblia[10]; //na dimioyrgei L biblia (isos ginei struct)
for(i = 0; i<K1; i++){ //k1 tyxaies topothetiseis
bibl.place_book();
}
for(i = 0; i<K2; i++){ //k2 tyxaies afaireseis
bibl.take_book();
}
bibl.print(); //ektyposh ths bibliothikis
return 0;
}
bibliothiki::bibliothiki(){
cout<< "construct bibliyhikis"<<endl;
for (int i = 0; i < 10; ++i)
b[i] = NULL;
}
bibliothiki::~bibliothiki(){
cout<< "destructor bibliyhikis"<<endl;
}
void bibliothiki::place_book(biblia bibl){
int i = 0;
while(b[i] < 10){
if (b[i] == NULL)
b[i] = bibl;
else
i++;
}
}
biblia take_book(int number){
biblia a;
a = b[number];
b[number] = NULL;
return a;
}
void print(){
int i = 0;
while(b[i] != NULL){
count<<b[i]<<endl;
i++;
}
}