-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuman.cpp
More file actions
35 lines (30 loc) · 785 Bytes
/
Human.cpp
File metadata and controls
35 lines (30 loc) · 785 Bytes
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
//
// Created by Mac on 09/01/2024.
//
#include "Human.h"
std::string randomLineFromFile(std::string fileName) {
std::string line;
std::ifstream File(fileName);
std::random_device rd;
srand(time(0));
int linesInFile;
if(fileName=="names.txt"){
linesInFile=linesInNames;
} else{
linesInFile=linesInSurnames;
}
std::uniform_int_distribution<int> distribution(0, linesInFile);
int randomLine = distribution(rd);
int numOfLines=0;
while(std::getline(File, line)){
numOfLines++;
if(numOfLines==randomLine)
break;
}
return line;
}
void Human::action() {}
std::ostream& operator<<(std::ostream &os, Human& human){
os<< human.name<<" "<<human.surname<<" "<<human.age;
return os;
}