1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/sxx1111-elevator_simulation

Клонировать/Скачать
Person.cpp 2.5 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Shixinxin Отправлено 07.01.2019 20:52 9b3613b
#include "Person.h"
#include "Rule.h"
#include <iostream>
using namespace std;
Person::Person (int n) {
no = n; // 设置编号
sign = true; // 进入仿真
startTime = Rule::random(Rule::M, 0); // 到达电梯的时间
currentFloor = 1; // 设置当前楼层
while(currentFloor == (toFloor = Rule::random(Rule::FloorNumber))); //设置欲往楼层
elevatorNo = -1; // 设置选择电梯编号
isInElevator = false; // 是否在电梯中
isWait = false; // 是否处于等待状态
restTime = 0; // 休息时间
pickTime = 0; // 上下电梯时间
L = Rule::random(Rule::MaxL); // 乘坐多少次电梯
hL = 0; // 已经乘坐的电梯次数
weight = Rule::random(100) > 80 ? 2 : 1;// 设置乘客重量
}
// 获取编号
int Person::getNo () {
return no;
}
// 休息时间减少
void Person::decreaseRestTime () {
restTime = restTime > 0 ? restTime - 1 : 0;
}
void Person::inElevator (int tF) {
// 进入电梯
isInElevator = true;
// 设置前往楼层
toFloor = tF;
}
// 获取开始时间
int Person::getStartTime () {
return startTime;
}
// 设置当前楼层
void Person::setCurrentFloor (int cF) {
currentFloor = cF;
}
// 获取当前楼层
int Person::getCurrentFloor () {
return currentFloor;
}
// 设置电梯编号
void Person::setElevatorNo (int en) {
elevatorNo = en;
}
// 获取电梯编号
int Person::getElevatorNo () {
return elevatorNo;
}
// 设置欲前往楼层
void Person::setToFloor () {
while(currentFloor == (toFloor = Rule::random(Rule::FloorNumber)));
}
void Person::setToFloor (int tF) {
toFloor = tF;
}
// 获取欲前往楼层
int Person::getToFloor () {
return toFloor;
}
// 设置停留时间
void Person::setRestTime () {
restTime = Rule::random(Rule::maxWaitTime, Rule::minWaitTime);
}
// 获取停留时间
int Person::getRestTime () {
return restTime;
}
// 设置是否在电梯内
bool Person::setIsInElevator (bool ie) {
isInElevator = ie;
}
// 判断是否在电梯内
bool Person::getIsInElevator () {
return isInElevator;
}
// 设置人是否正在上下电梯
void Person::setPickTime (int t) {
pickTime = t;
}
// 上下时间减少一秒
void Person::decreasePickTime() {
if(pickTime > 0) pickTime--;
}
// 获取人是否正在上下电梯
int Person::getPickTime () {
return pickTime;
}
// 设置乘坐电梯次数
void Person::setHL () {
// 乘坐电梯次数+1
if(hL <= L) hL ++;
}
// 获取乘坐电梯次数
int Person::getHL () {
return hL;
}
// 获取最大乘梯数
int Person::getL () {
return L;
}
// 设置仿真标志位
void Person::setSign (bool s) {
sign = s;
}
// 获取仿真标志位
bool Person::getSign () {
return sign;
}
// 获取乘客重量
int Person::getWeight() {
return weight;
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/sxx1111-elevator_simulation.git
git@api.gitlife.ru:oschina-mirror/sxx1111-elevator_simulation.git
oschina-mirror
sxx1111-elevator_simulation
sxx1111-elevator_simulation
master