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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Person
{
friend class Island;
private:
char status;
int island;
public:
Person *next;
Person();
Person(char&, int&);
char setStatus(char&);
};
Person::Person()
{
}
Person::Person(char& s, int& i)
{
status = s;
island = i;
next = NULL;
}
char Person::setStatus(char& s)
{
status = s;
}
class Island
{
private:
Person *root;
public:
Island();
~Island();
void addPerson(char&, int&);
void work(int&, int&, int&, int&, int&, int&);
};
Island::Island()
{
root = new Person();
root = NULL;
}
Island::~Island()
{
delete root;
}
void Island::addPerson(char& healthstatus, int& island)
{
Person *new_civilian = new Person(healthstatus, island);
if(root == NULL)
{
root = new_civilian;
return;
}
else
{
Person *temp_person = root;
while(temp_person->next != NULL)
{
temp_person = temp_person->next;
}
temp_person->next = new_civilian;
}
}
void Island::work(int& first_infected, int& contact_rate, int& transmission_probability, int& infected_period, int& infectious_period, int& num)
{
Person *temp_person = root;
int count = 0;
char infectedstatus = 'i';
while(every_infected != 0 && every_infectious != 0)
{
while(temp_person != NULL)
{
for(int l=0; l<num; l++)
{
for(int m=0; m<first_infected; m++)
{
if(temp_person->island == l+1)
{
temp_person->setStatus(infectedstatus);
}
}
break;
}
cout << temp_person->status << endl;
cout << temp_person->island << endl;
temp_person = temp_person->next;
}
}
}
|