当前位置: 首页>>代码示例>>C++>>正文


C++ Database::AddComposer方法代码示例

本文整理汇总了C++中Database::AddComposer方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::AddComposer方法的具体用法?C++ Database::AddComposer怎么用?C++ Database::AddComposer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database::AddComposer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(){
	int in_yob, ranking;
	string in_first_name, in_last_name, in_genre, in_fact, last_name, in_composer;
	char selection, choice;

	Database myDB;
	
	do {
		DisplayMenu();
		cin >> selection;
		cout << endl;
		while (!cin || selection < 48 || selection > 53){
			cin.clear();
			cout << "Please make a valid selection" << endl;
			DisplayMenu();
			cin >> selection;
		}
		switch (selection) {
			case 49 : {
				cout << "First Name: ";
				cin >> in_first_name;
				cout << "Last Name: ";
				cin >> in_last_name;
				cout << "Genre: ";
				cin >> in_genre;
				cout << "Year of Birth: ";
				cin >> in_yob;
				while (!cin || in_yob < 1){
					cin.clear();
					cin.ignore(1000, '\n');
					cout << "Enter a positive integer for year of birth: ";
					cin >> in_yob;
				}
				cout << "Fact: ";
				cin >> in_fact;
				last_name = in_last_name;
				transform(last_name.begin(), last_name.end(), last_name.begin(), ::tolower);
				Composer& last_name = myDB.AddComposer(in_first_name, in_last_name,
															in_genre, in_yob, in_fact);
				cin.clear();
			}	break;
			case 50 : {
				cout << "Enter composers last name: ";
				cin >> in_last_name;
				cout << endl;
				myDB.GetComposer(in_last_name);
			}	break;
			case 51 : {
				do{
					cout << "Which composer would you like to promote/demote? " << endl;
					cin >> in_composer;
					cout << "Set ranking: ";
					cin >> ranking;
					while(ranking > 10 || ranking < 1){
						cin.clear();
						cout << "Please enter a ranking between 1 and 10" << endl;
						cout << "Set ranking: ";
						cin >> ranking;
					}
					cout << endl;
					myDB.SetRanking(in_composer, ranking);
					myDB.GetComposer(in_composer);
					cout << "Would you like to change another ranking? (y/n)";
					cin >> choice;
				}while (::tolower(choice) == 121);
				cin.clear();
			}	break;
			case 52 : {
				myDB.DisplayAll();
			}	break;
			case 53 : {
				myDB.DisplayByRank();
			} break;
			case 48 :
				break;
			default :
				cout << "Please make a valid selection" << endl;
		}
	} while (selection != 48);	
}
开发者ID:GrierPhillips,项目名称:google.cpp.course,代码行数:80,代码来源:compopser_database.cpp


注:本文中的Database::AddComposer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。