本文整理汇总了C++中Event::AddEntrant方法的典型用法代码示例。如果您正苦于以下问题:C++ Event::AddEntrant方法的具体用法?C++ Event::AddEntrant怎么用?C++ Event::AddEntrant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event::AddEntrant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddEntrants
/**
* Member function to add a new entrant to an event.
*/
void EventCreator::AddEntrants() {
using namespace std;
int eventIndex = ChooseEvent();
int numEntrants = 0;
string name;
int id;
char course;
//if user picked an event
if(eventIndex >= 0) {
Event event = events[eventIndex];
//check if we have some courses already.
if(event.GetCourses().size() > 0) {
cout << "Enter number of entrants to add: " << endl;
do {
numEntrants = scanner.ReadInt();
if(numEntrants <=0) {
cout << "Not a valid number of entrants" << endl;
} else if (numEntrants > 50) {
cout << "Too many entrants to create at once!" << endl;
}
} while (numEntrants <= 0);
for(int i = 0; i < numEntrants; i++) {
cout << "Enter entrant's name: " << endl;
name = scanner.ReadString(50);
course = ChooseCourse(event);
id = event.GetEntrants().size()+1;
event.AddEntrant(name, id, course);
events[eventIndex] = event;
}
} else {
cout << "You must create at least one course first." << endl;
}
}
}