Advertisement
udaykumar1997

premeiroV5.cpp

Sep 23rd, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.35 KB | None | 0 0
  1. // re4(9).cpp
  2. /* this program demonstrates the use of structures in structures( complex structures ) */
  3. /*
  4. this program makes use of complex structures and default arguments for functions.
  5. */
  6. /* this file hasn't yet been added to the revamp-4 project, so it's totally anonymous
  7.    therefore maintain caution */
  8.  
  9. #include<iostream>
  10. const int fish_net=35;
  11.  
  12. using namespace std;
  13.  
  14.      
  15.       struct ST_fish{int fsii,fnii;       double ocean,ftii,total_fish;};        // structure ' 1 '
  16.       struct ST_sail{int sailorno; double sailor_salary;};                       // structure ' 2 '
  17.       char *ioi[]={"Indian ocean"},*poi[]={"Pacific ocean"},*aoi[]={"Atlantic ocean"},*aroi[]={"Artic ocean"};// pointers
  18.      
  19. class crcpara{                                                           // this is a class of menu related functions and mainly outputs
  20. public:
  21.        crcpara(void){}; ~crcpara(){};
  22.        void chooser_disp(){
  23.            cout << "\t no:      name of the ocean \n";
  24.            cout << "\t 1        "<<*ioi<<" \n";
  25.            cout << "\t 2        "<<*poi<<" \n";
  26.            cout << "\t 3        "<<*aoi<<" \n";
  27.            cout << "\t 4        "<<*aroi<<" \n";};
  28.        double chooser_cho(int lock){
  29.            switch(lock){
  30.            case 1:
  31.                 {return 12.55;break;}
  32.            case 2:
  33.                 {return 11.67;break;}
  34.            case 3:
  35.                 {return 10.34;break;}
  36.            case 4:
  37.                 {return 9.43;break;}
  38.            default:
  39.                 {cout << " do not counterflirt with the program "<< endl;break;}};
  40.        }
  41.        void confirfish(ST_fish inf);                                           // confirmation function
  42. };
  43.  
  44. class crcpuru{                                                      // this is a class of caluclaton related functions
  45.       private:
  46.               int fsi,fni;double fti;
  47.       public:
  48.              crcpuru(int a,int b,double c){fsi=a;fni=b;fti=c;};  ~crcpuru(){};// constructor, deconstructor
  49. /* NOTE unused deconstructors may sometimes flag errors */
  50.              double fish_finder(int fsi,int fni,double fti){                            // func
  51.              return fni*fti*fish_net*fsi;                     // will calculate the number of fish that comes out of each ship in one hour
  52.              };
  53.              
  54.              char* oceanfinder(double loc){
  55.                   if (loc==12.55){return *ioi;}
  56.                   else if (loc==11.67){return *poi;}
  57.                   else if (loc==10.34){return *aoi;}
  58.                   else if (loc==9.43) {return *aroi;}
  59.                   else {cout << "error";};
  60.              };
  61. };
  62.  
  63. class decco{                                                       // this class contains decoration related functions
  64.       public:
  65.              decco(void){};       ~decco(){};
  66.       char baline(int a=64, char b=196)
  67.           {
  68.              for(int kk=0;kk<=a;kk++){cout<<b;}cout<<endl;
  69.           };
  70. };
  71.  
  72.     crcpuru coco(0,0,0);                                                      // object
  73. void crcpara::confirfish(ST_fish inf){
  74.                cout << endl << "\t-> your will be fishing in the " << coco.oceanfinder(inf.ocean);
  75.                cout<<endl<<"\t-> number fo fish ships employed : "<<inf.fsii;
  76.                cout<<endl<<"\t-> number of fish nets on board each ship : "<<inf.fnii;
  77.                cout<<endl<<"\t-> nuber of hours of stationing of each ship : "<<inf.ftii;
  78. };
  79.  
  80. int main()
  81. {
  82.     int damn=0;                                                               //' 1 ' automatic variable
  83.     crcpara plm; decco dec;                                                   // object
  84.     crcpuru (0,0,0);                                                      // object
  85. /* NOTE objects must be declared for constructors */
  86.     ST_fish fish={0,0,0,0,0}; ST_sail sail={0,0};                             // structure's declaration
  87.     cout << " hello, this program is for enterpreuners and NOT for kids, \n so maintain caution "<<endl;
  88.     dec.baline();
  89.     cout << " please choose the ocean which your going to fish in "<<endl;
  90.     plm.chooser_disp();
  91.     cin >> damn;
  92.     fish.ocean=plm.chooser_cho(damn);
  93.     dec.baline();
  94.     cout<<"Q. please enter the number of ships you will be sending to fish "<<endl;
  95.     cin>>fish.fsii;
  96.     dec.baline();
  97.     cout<<"Q. please enter the number of fish-nets that each ship can hold \n on board at a time "<<endl;
  98.     cin>>fish.fnii;
  99.     dec.baline(64,177);
  100.     cout<<" remember each fish net can capture only 35 fish to the max, "<<endl;
  101.     cout<<" so the program will calclate taking into consideration only that value " <<endl;
  102.     dec.baline(64,177);
  103.     cout<<"Q. please enter the number of hours your are planning to station \n your ships at the spot "<<endl;
  104.     cin>>fish.ftii;
  105.     fish.total_fish=coco.fish_finder(fish.fsii,fish.fnii,fish.ftii);
  106.     dec.baline();
  107.     cout<<"Q. please enter the total number of sailor on each ship "<<endl;
  108.     cin>>sail.sailorno;
  109.     dec.baline();
  110.     cout<<"Q. please enter the ammount of money that you will be paying for each sailor "<<endl;
  111.     cin>>sail.sailor_salary;
  112.     plm.confirfish(fish);                            //  plm.confirfish(fish); // confirmation function // repair pending
  113. // the confir fish function still under construction and the option to edit the configs from this function will come soon
  114.     cout<<"\t the numbe rof ";
  115.     cin.ignore();
  116.     cin.get();
  117.     return 0;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement