-
Notifications
You must be signed in to change notification settings - Fork 0
/
Inventory.cpp
77 lines (71 loc) · 1.54 KB
/
Inventory.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
#include "Inventory.h"
#include <iostream>
#include "Customer.h"
#include "Date.h"
#include "Tablet.h"
#include <fstream>
Inventory::Inventory(int num)
{
//ctor
numTabs=num;
loanTabs=0;
brokenTabs=0;
allTabs();
}
Inventory::~Inventory()
{
//dtor
}
void Inventory::allTabs()
{
fstream file("id.txt");
fstream file2("available.txt");
fstream file3("loan.txt");
fstream file4("broken.txt");
if(!file.is_open())
{
cout<<"FILES NOT FOUND!";
system("PAUSE");
exit(0);
}
for(int i=0; i<numTabs; i++)
{
string ID;
getline(file,ID);
tabs[i]=new Tablet(false);
tabs[i]->SetID(ID);
bool b=tabs[i]->checkBroken();
if(b)
{
file4<<tabs[i]->GetID()<<endl;
tabs[i]->SetonLoan(false);
}
else if(tabs[i]->GetonLoan())
{
file3<<tabs[i]->GetID()<<endl;
}
else file2<<tabs[i]->GetID()<<endl;
}
file.clear();
file2.clear();
file3.clear();
file4.clear();
file.close();
file2.close();
file3.close();
file4.close();
}
void Inventory::loadAllTabs()
{
for(int i=0; i<numTabs; i++)
{
cout<<"Tablet ID: "<<tabs[i]->GetID()<<endl;
cout<<"On Loan: "<<tabs[i]->GetonLoan()<<endl;
if(tabs[i]->GetonLoan())
{
cout<<"Customer: "<<endl;
tabs[i]->GetloanedTo().printInfo();
cout<<"Return Date: "<<tabs[i]->GetreturnDate().getDate()<<endl;
}
}
}