-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlamp.cpp
45 lines (38 loc) · 810 Bytes
/
lamp.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
#include "lamp.h"
Lamp::Lamp(string m, string t, int i):
Accessory(m,t,i,true)
{
}
void Lamp::Initialize()
{
string f;
string ty,ma;
ifstream lampf("lamp.txt");
int linenumber=0;
if(lampf.is_open()){
while(!lampf.eof()){
linenumber++;
getline(lampf,ty);
}
lampf.close();
lampf.open("lamp.txt");
int line=RandomNumber(linenumber);
linenumber=0;
while(!lampf.eof()){
if(line==linenumber){
lampf>>ma>>ty;
break;
}
getline(lampf,f);
linenumber++;
}
}else{
cout<<"FATAL ERROR, lamp.txt file is not openable"<<endl;
}
lampf.close();
this->setMaker(ma);
this->setType(ty);
}
Lamp::Lamp()
{
}