📄 elevator.h
字号:
// elev.h
// header file for elevators
#ifndef ELEVATOR_H //don't let this file be included
#define ELEVATOR_H //twice in the same source file
#include "msoftcon.h" //for console graphics
const int NUM_FLOORS = 20; //number of floors
enum Direction { UP, DOWN, STOP };
const int LOAD_TIME = 3; //loading/unloading time (ticks)
const int SPACING = 7; //visual spacing between cars
const int BUF_LENGTH = 80; //length of utility string buffer
struct Elevator
{
int current_floor; //where are we? (0 to nf-1)
int prev_floor; //where were we? (0 to nf-1)
Direction current_dir; //which way are we going?
int destination[NUM_FLOORS]; //selected by occupants
int loading_timer; //non-zero if loading
int unloading_timer; //non-zero if unloading
};
struct Building
{
Elevator* car_one; //ptrs to the car
//array of up/down buttons
int floor_request[2][NUM_FLOORS]; // 0=UP, 1=DOWN //第一维表示方向,第二维表示楼层
};
void elevatorInitialization(Elevator* ep);
void buildingInitialization();
void clear_botttom_three_line();
void show_floor_reqs();
void get_user_floor_reqs();
void car_tick1(Elevator* ep);
void car_tick2(Elevator* ep);
void car_display(Elevator* ep);
void dests_display(Elevator* ep);
void decide(Elevator* ep);
void move(Elevator* ep);
void get_destinations(Elevator* ep);
#endif // ELEVATOR_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -