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


C++ Menu::Popumenu方法代码示例

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


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

示例1: main

//Begin excution of function main
int main()
{
	Menu *menuPtr[5];   //declare an array of pointer of class type Menu
   Menu menu;          //declare an object of the class type Menu

   Insurpolicy *Bpolicy;  //declare a pointer to the base class

   Homeinsurpolicy HCpolicy;         //declare an object of the class type Homeinsurpolicy
   Homeinsurpolicy blankHCpolicy;    //declare an object of the class type Homeinsurpolicy for initializing objects of its type to blank
   fstream HomeFile ("HomeFile.txt", ios::in | ios::out | ios::binary);   //create a file for storing home insurance

   Lifeinsurpolicy LCpolicy;        //declare an object of the class type Lifeinsurpolicy
   Lifeinsurpolicy blankLCpolicy;   //declare an object of the class type Lifeinsurpolicy for initializing objects of its type to blank
   fstream LifeFile("LifeFile.txt", ios::in | ios::out | ios::binary);    //create a file for storing life insurance

   MVinsurpolicy   MVCpolicy;       //declare an object of the class type MVinsurpolicy
   MVinsurpolicy   blankMVCpolicy;  //declare an object of the class type MVinsurpolicy for initializing objects of its type to blank
   fstream MVFile ("MVFile.txt", ios::in | ios::out | ios::binary);  //create a file for storing motor vehicle insurance

   int Option;  //Menu selection/option
   int Polopt;  //policy selection/option

   Startup( );  //call a function to display boot up screen

   //exit program if fstream cannot open file
   if (!HomeFile)
   {
   	cerr << "HomeFile File could not be opened."<<endl;  //display error
      exit (1);
   }// end if

   //exit program if fstream cannot open file
   if (!LifeFile)
   {
   	cerr << "LifeFile File could not be opened."<<endl;  //display error
      exit (1);
   }// end if

   //exit program if fstream cannot open file
   if (!MVFile)
   {
   	cerr << "MVFile File could not be opened."<<endl;  //display error
      exit (1);
   }//end if

   system("title True Value Insurance Company Ltd.");  //programme title

   Option = menu.Popumenu(menuPtr);   //call function to get user option

   //while the option is not 5, do the following
   while (Option != 5) {

      //do a case on the option
   	switch (Option) {

      	case 1:           //Add policy

               // call a function to get the policy option that the user wants and set it to Polopt
               Polopt = Poloption();
               //do a case on the Polopt
               switch(Polopt) {
						case 1:                               //if 1 add home policy
                     HCpolicy.AddHomeDisplayScreen( );  //Create display screen
                     HCpolicy.addPolicy(HomeFile);      //call object method to add policy and send the home file to it
                     HCpolicy = blankHCpolicy;          //then initialize the object to be blank
                  	break;

						case 2:                              //if 2 add life policy
                     LCpolicy.AddLifeDisplayScreen( ); //Create display screen
                     LCpolicy.addPolicy(LifeFile);     //call object method to add policy and send the life file to it
                     LCpolicy = blankLCpolicy;         //then initialize the object to be blank
                  	break;

						case 3:                             //if 3 add motor vehicle policy
                     MVCpolicy.AddMotovDisplayScreen( ); //Create display screen
                     MVCpolicy.addPolicy(MVFile);        //call object method to add policy and send the motor vehicle file to it
                     MVCpolicy = blankMVCpolicy;         //then initialize the object to be blank
                  	break;

               }// end switch

         	break;

      	case 2: 				//Delete policy

         		// call a function to get the policy option that the user wants and set it to Polopt
               Polopt = Poloption();
               //do a case on the Polopt
               switch(Polopt) {
						case 1:                            //if 1 delete home policy
                  	HCpolicy.DeleteHome(HomeFile);  //call object method to delete policy and send the home file to it
                     HCpolicy = blankHCpolicy;       //then initialize the object to be blank
                  	break;

						case 2:                           //if 2 delete life policy
                     LCpolicy.DeleteLife(LifeFile); //call object method to delete policy and send the life file to it
                     LCpolicy = blankLCpolicy;      //then initialize the object to be blank
                  	break;

//.........这里部分代码省略.........
开发者ID:nnation,项目名称:cplusplus-insurance-policy-project,代码行数:101,代码来源:database.cpp


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