标签:namespace eva ret wait 无法 include 程序设计 结构 stop
下面是C++中的电梯类的代码
class Elevator
{
public:
int time;//总时间
int requesttime;//请求时间
int waitfloor;//请求层数
int requestfloor;//目的层数
int currentfloor;//当前层数
Elevator();
~Elevator();
int gotofloor(int requesttime,int requestfloor,int time,int waitfloor,int currentfloor);//前往目的层数
int stop(int time,int currentfloor);//停止
};
#include "stdafx.h"
#include "Elevator.h"
#include<iostream>
#include<stdio.h>
using namespace std;
Elevator::Elevator()
{
}
Elevator::~Elevator()
{
}
int Elevator::gotofloor(int requesttime,int requestfloor,int time,int waitfloor,int currentfloor)
{
int g, h;
if (time < requesttime)time = requesttime;
g = waitfloor - currentfloor;
if (g < 0)g = -g;
h = waitfloor - requestfloor;
if (h < 0)h = -h;
time = time + g + h;
return time;
}//电梯送乘客前往目的地
int Elevator::stop(int time,int currentfloor)
{
time++;
return time;
}//电梯停靠
标签:namespace eva ret wait 无法 include 程序设计 结构 stop
原文地址:https://www.cnblogs.com/Destr/p/8999025.html