Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct list_node {
- train* data;
- list_node* next;
- }
- struct train {
- string destination;
- int id;
- unsigned int arrivalTime;
- }
- class TrainList {
- list_node *head;
- public:
- TrainList() {head = NULL;}
- ~TrainList();
- bool checkTrainIdValid(int id);
- void add();
- void remove();
- void show();
- void save();
- void load();
- }
- TrainList::~TrainList() {
- while (head != NULL) {
- list_node *tmp = head->next;
- delete head;
- head = tmp;
- }
- }
- bool TrainList::checkTrainIdValid(int id) {
- list_node *iter = head;
- while (iter != NULL) {
- if (iter->id == id) {
- cerr << "Train with such id already exists!!!" << endl;
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement