-
Notifications
You must be signed in to change notification settings - Fork 0
/
main3.cc
41 lines (40 loc) · 1.02 KB
/
main3.cc
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
#include <iostream>
#include <vector>
#include "person.h"
#include "population.h"
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main(){
int npeople;
float probs,innoc;
// Initialze and set the values needed
cout<<"How many people ?"<<endl;
cin>>npeople;
cout<<"Infection chance ?"<<endl;
cin>>probs;
cout<<"Vaccination rate ?"<<endl;
cin>>innoc;
// first we create the population, then innoculate
// innoculate first to prevent the innoculation from "saving" the target
Population population(npeople,probs);
population.innoculation(innoc);
population.random_infection();
int step=0;
srand(time(NULL));
while(population.count_infected()!=0)
{
step+=1;
cout<< "In step "<<setw(3)<<step<<" ";
population.Printer();
float badluck=(float) rand() / (float) RAND_MAX;
population.update();
population.setprob(badluck);
};
cout<<"In step "<<setw(3)<<step+1<<" ";
population.Printer();
cout<<"Disease ran its course by step "<<step+1<<endl;
cout<< population.sickcount()<<" got sick."<<endl;
return 0;
}