Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // re4(9).cpp
- /* this program demonstrates the use of structures in structures( complex structures ) */
- /*
- this program makes use of complex structures and default arguments for functions.
- */
- /* this file hasn't yet been added to the revamp-4 project, so it's totally anonymous
- therefore maintain caution */
- #include<iostream>
- const int fish_net=35;
- using namespace std;
- struct ST_fish{int fsii,fnii; double ocean,ftii,total_fish;}; // structure ' 1 '
- struct ST_sail{int sailorno; double sailor_salary;}; // structure ' 2 '
- char *ioi[]={"Indian ocean"},*poi[]={"Pacific ocean"},*aoi[]={"Atlantic ocean"},*aroi[]={"Artic ocean"};// pointers
- class crcpara{ // this is a class of menu related functions and mainly outputs
- public:
- crcpara(void){}; ~crcpara(){};
- void chooser_disp(){
- cout << "\t no: name of the ocean \n";
- cout << "\t 1 "<<*ioi<<" \n";
- cout << "\t 2 "<<*poi<<" \n";
- cout << "\t 3 "<<*aoi<<" \n";
- cout << "\t 4 "<<*aroi<<" \n";};
- double chooser_cho(int lock){
- switch(lock){
- case 1:
- {return 12.55;break;}
- case 2:
- {return 11.67;break;}
- case 3:
- {return 10.34;break;}
- case 4:
- {return 9.43;break;}
- default:
- {cout << " do not counterflirt with the program "<< endl;break;}};
- }
- void confirfish(ST_fish inf); // confirmation function
- };
- class crcpuru{ // this is a class of caluclaton related functions
- private:
- int fsi,fni;double fti;
- public:
- crcpuru(int a,int b,double c){fsi=a;fni=b;fti=c;}; ~crcpuru(){};// constructor, deconstructor
- /* NOTE unused deconstructors may sometimes flag errors */
- double fish_finder(int fsi,int fni,double fti){ // func
- return fni*fti*fish_net*fsi; // will calculate the number of fish that comes out of each ship in one hour
- };
- char* oceanfinder(double loc){
- if (loc==12.55){return *ioi;}
- else if (loc==11.67){return *poi;}
- else if (loc==10.34){return *aoi;}
- else if (loc==9.43) {return *aroi;}
- else {cout << "error";};
- };
- };
- class decco{ // this class contains decoration related functions
- public:
- decco(void){}; ~decco(){};
- char baline(int a=64, char b=196)
- {
- for(int kk=0;kk<=a;kk++){cout<<b;}cout<<endl;
- };
- };
- crcpuru coco(0,0,0); // object
- void crcpara::confirfish(ST_fish inf){
- cout << endl << "\t-> your will be fishing in the " << coco.oceanfinder(inf.ocean);
- cout<<endl<<"\t-> number fo fish ships employed : "<<inf.fsii;
- cout<<endl<<"\t-> number of fish nets on board each ship : "<<inf.fnii;
- cout<<endl<<"\t-> nuber of hours of stationing of each ship : "<<inf.ftii;
- };
- int main()
- {
- int damn=0; //' 1 ' automatic variable
- crcpara plm; decco dec; // object
- crcpuru (0,0,0); // object
- /* NOTE objects must be declared for constructors */
- ST_fish fish={0,0,0,0,0}; ST_sail sail={0,0}; // structure's declaration
- cout << " hello, this program is for enterpreuners and NOT for kids, \n so maintain caution "<<endl;
- dec.baline();
- cout << " please choose the ocean which your going to fish in "<<endl;
- plm.chooser_disp();
- cin >> damn;
- fish.ocean=plm.chooser_cho(damn);
- dec.baline();
- cout<<"Q. please enter the number of ships you will be sending to fish "<<endl;
- cin>>fish.fsii;
- dec.baline();
- cout<<"Q. please enter the number of fish-nets that each ship can hold \n on board at a time "<<endl;
- cin>>fish.fnii;
- dec.baline(64,177);
- cout<<" remember each fish net can capture only 35 fish to the max, "<<endl;
- cout<<" so the program will calclate taking into consideration only that value " <<endl;
- dec.baline(64,177);
- cout<<"Q. please enter the number of hours your are planning to station \n your ships at the spot "<<endl;
- cin>>fish.ftii;
- fish.total_fish=coco.fish_finder(fish.fsii,fish.fnii,fish.ftii);
- dec.baline();
- cout<<"Q. please enter the total number of sailor on each ship "<<endl;
- cin>>sail.sailorno;
- dec.baline();
- cout<<"Q. please enter the ammount of money that you will be paying for each sailor "<<endl;
- cin>>sail.sailor_salary;
- plm.confirfish(fish); // plm.confirfish(fish); // confirmation function // repair pending
- // the confir fish function still under construction and the option to edit the configs from this function will come soon
- cout<<"\t the numbe rof ";
- cin.ignore();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement