Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Class Zoology-Object Oriented Programming-C Language Codes, Exercises of Object Oriented Programming

Objective of this cours is to develop effective computer programming skills in solving complex problems and to learn adequate and operational software organization in developing real life engineering solutions using powerful object oriented paradigm of the language. It includes: Viewing, Lab, Information, Return, Valid, Option, Token, Number, Input, Location, Apparatus

Typology: Exercises

2011/2012

Uploaded on 07/31/2012

netu
netu 🇮🇳

4.5

(4)

55 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
#include "botny_lab.h"
#include"Animals.h"
class zoology_lab
{
stu student_zoology[100];
float z;
int record_no,animal_edit,zoology_apparatus_edit,b;
rec_handler record_zoology[100];
attendant zoology_attendant;
location zoology_lab_location;
capacity zoology_lab_capacity;
timings zoology_lab_timings;
Animal zoology_animals[30];
apparatus zoology_apparatus[20];
public:
zoology_lab():record_no(0),animal_edit(0),zoology_apparatus_edit(0)
{}
int zoology_menu()
{
int a;
while(1)
{
q4:
cin.clear();
cout<<"PRESS \n 1 FOR VIEWING LAB INFORMATION \n";
cout<<"2 FOR EDITING DATA \n";
cout<<"3 FOR HAVING A LAB SESSION \n";
cout<<"4 FOR VIEWING YOUR LAB PARTICULARS \n";
cout<<"5 TO VIEW STUDENT RECORD \n";
cout<<"6 TO RETURN TO MAIN MENU \n";
cin>>z;
system("cls");
flushall();
a=z;
if(z-a>0)
{
cout<<"Not a valid option \n";flushall();
goto q4;
}
if ( a!=1 && a!=2 && a!=3 && a!=4 && a!=5 && a!=6)
{
cout << "Not a Valid choice \n" ;
cin.clear () ;
cin.ignore (INT_MAX,'\n') ;
continue ;
}
switch(a)
{
case 1:
get_rec();
break;
case 2:
set_rec();
break;
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Class Zoology-Object Oriented Programming-C Language Codes and more Exercises Object Oriented Programming in PDF only on Docsity!

#include "botny_lab.h" #include"Animals.h" class zoology_lab { stu student_zoology[100]; float z; int record_no,animal_edit,zoology_apparatus_edit,b; rec_handler record_zoology[100]; attendant zoology_attendant; location zoology_lab_location; capacity zoology_lab_capacity; timings zoology_lab_timings; Animal zoology_animals[30]; apparatus zoology_apparatus[20]; public: zoology_lab():record_no(0),animal_edit(0),zoology_apparatus_edit(0) {} int zoology_menu() { int a; while(1) { q4: cin.clear(); cout<<"PRESS \n 1 FOR VIEWING LAB INFORMATION \n"; cout<<"2 FOR EDITING DATA \n"; cout<<"3 FOR HAVING A LAB SESSION \n"; cout<<"4 FOR VIEWING YOUR LAB PARTICULARS \n"; cout<<"5 TO VIEW STUDENT RECORD \n"; cout<<"6 TO RETURN TO MAIN MENU \n"; cin>>z; system("cls"); flushall(); a=z; if(z-a>0) { cout<<"Not a valid option \n";flushall(); goto q4; } if ( a!=1 && a!=2 && a!=3 && a!=4 && a!=5 && a!=6) { cout << "Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; continue ; } switch(a) { case 1: get_rec(); break; case 2: set_rec(); break;

case 3: lab_session(); break; case 4: cout<<"ENTER YOUR TOKEN NUMBER\n";cin>>b; if(b<1||b>record_no) { cout<<"WRONG INPUT\n"; break; } view_lab(b); break; case 5: cout<<"ENTER REGISTRATION NUMBER OF STUDENT\n"; cin>>b; if(b<0||b>99) { cout<<"WRONG INPUT\n"; break; } view_STUDENT(b); break; case 6: return 1; break; } } } void get_rec() {

cout<<"^^^^^^^^^^^^^^^^^^^^^LAB LOCATION^^^^^^^^^^^^^^^^^^^^^"<<endl<<endl; cout<<"COLLEGE NAME------ "<<zoology_lab_location.g1_r()<<endl; cout<<"LAB NAME------ "<<zoology_lab_location.g2_r()<<endl<<endl; cout<<"^^^^^^^^^^^^^^^^^^^^^LAB TIMINGS^^^^^^^^^^^^^^^^^^^^^^"<<endl<<endl; cout<<"OPENING TIME-------"<< zoology_lab_timings.g_rec()<<"hrs"<<endl; cout<<"CLOSING TIME-------"<< zoology_lab_timings.g1_rec()<<"hrs"<<endl<<endl; cout<<"^^^^^^^^^^^^^^^^^^^^^LAB CAPACITY^^^^^^^^^^^^^^^^^^^^^"<<endl<<endl; cout<<"TOTAL NUMBER OF STUDENTS-------- "<<zoology_lab_capacity.get_students()<<endl<<endl; cout<<"^^^^^^^^^^^^^^^LAB ATTENDANT PARTICULARS^^^^^^^^^^^^^^"<<endl<<endl; cout<<"NAME------"<<zoology_attendant.get_rc()<<endl; cout<<"EXPERIANCE--------"<<zoology_attendant.gt_rc()<<endl; cout<<"REG NO--------- "<<zoology_attendant.g_rc()<<endl<<endl;

cin.ignore (INT_MAX,'\n') ; continue ; }

switch(a) { case 1: cout<<"enter name of attendant\n"; flushall(); cin.getline(zoology_attendant.get_rc(),100,'\n'); system("cls"); cout<<"enter experiance of attendant\n"; flushall(); cin.getline(zoology_attendant.gt_rc(),100,'\n'); system("cls"); cout<<"enter registration number of attendant\n"; flushall(); cin.getline(zoology_attendant.g_rc(),100,'\n'); system("cls"); break; case 2: cout<<"enter name of college\n"; flushall(); cin.getline(zoology_lab_location.g1_r(),100,'\n'); system("cls"); flushall(); cout<<"enter name of lab\n"; cin.getline(zoology_lab_location.g2_r(),100,'\n'); system("cls"); break; case 3: E: cin.clear(); cout<<"enter number of students which can be accumudated in lab\n"; flushall(); int k; cin>>k; system("cls"); if(k>0) { zoology_lab_capacity.get_students()=k; } else { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto E ; } system("cls"); break; case 4: F:

cin.clear(); cout<<"enter opening time of lab\n"; flushall(); k=0; cin>>k; system("cls"); if(k>=0 && k<=2400) { zoology_lab_timings.g_rec()=k; } else { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto F ; } system("cls"); G:

cin.clear(); cout<<"enter closing time of lab\n";

flushall(); k=0; cin>>k; system("cls"); if(k>=zoology_lab_timings.g_rec() && k<=2400) { zoology_lab_timings.g1_rec()=k; } else { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto G ; } system("cls"); break; case 5: H: cin.clear(); cout<<"PRESS 1 FOR NEW ANIMAL PRESS 2 FOR EDITING ANIMAL"; cin>>c; if(c!=1 && c!=2) { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto H ; } if(c==1)

flushall();

cin.getline(zoology_animals[d].get_specie(),100,'\n'); cin.sync(); system("cls"); int g; K: cin.clear(); cout<<"ENTER NUMBERS OF ANIMAL\n"; cin>>g; flushall(); if(g<0) { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto K ; } else { zoology_animals[d].get_numbers()=g; } system("cls"); } break; case 6: L: cin.clear(); cout<<"PRESS 1 FOR NEW APPARATUS PRESS 2 FOR EDITING APPARATUS"; cin>>c; if(c!=1 && c!=2) { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto L ; } if(c==1) { cout<<"ENTER NAME OF APPARATUS\n"; flushall();

cin>>zoology_apparatus[zoology_apparatus_edit].get_name(); flushall(); system("cls"); int g; M: cin.clear(); cout<<"ENTER NUMBER OF APPARATUS\n"; cin>>g; flushall(); if(g<0) {

cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto M ; } else {

zoology_apparatus[zoology_apparatus_edit].get_count()=g; } system("cls"); zoology_apparatus_edit++; } else{ e=zoology_apparatus_edit-1; N: cin.clear(); cout<<"ENTER SERIAL NUMBER OF APPARATUS (0-"<<e<<")\n"; cin>>d; if ( d<0 || d>e ) { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto N ; } cout<<"ENTER NAME OF APPARATUS\n"; flushall(); cin>>zoology_apparatus[d].get_name();cin.sync(); system("cls"); O: cin.clear(); int g; cout<<"ENTER QUANTITY OF APPARATUS\n"; flushall(); cin>>g; flushall(); if(g<0) { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto O ; } else { zoology_apparatus[d].get_count()=g; } system("cls"); } break; case 7: P: cin.clear();

&&(record_zoology[i].get_dt(3)==record_zoology[0].get_dt(3))&&(reco rd_zoology[i].get_t(1)==record_zoology[0].get_t(1))

&&(record_zoology[i].get_t(2)==record_zoology[0].get_t(2)) ) { cout<<"SORRY YOU CAN NOT HAVE LAB SESSION AS ON THE SPECIFIED DATE AND TIME THERE IS ANOTHER LAB\n"; break; } if( (record_zoology[0].get_c()>zoology_lab_capacity.get_students()) || (record_zoology[0].get_t(1)<zoology_lab_timings.g_rec()) || (record_zoology[0].get_t(2)>zoology_lab_timings.g1_rec()) ) { cout<<"SORRY YOU CAN NOT HAVE LAB SESSION AS SPECIFIED PARTICULARS ARE NOT MATCHING WITH LAB PARTICULARS\n"; break; } } if(i==100) { record_no++;

record_zoology[record_no].get_dt(1)=record_zoology[0].get_dt(1);

record_zoology[record_no].get_dt(2)=record_zoology[0].get_dt(2);

record_zoology[record_no].get_dt(3)=record_zoology[0].get_dt(3);

record_zoology[record_no].get_c()=record_zoology[0].get_c();

record_zoology[record_no].get_t(1)=record_zoology[0].get_t(1);

record_zoology[record_no].get_t(2)=record_zoology[0].get_t(2); cout<<"\n\n"<<"YOUR REQUEST FOR LAB IS ACCEPTED\nYOUR TOKEN NUMber is "<<record_no<<"\n\n"; } } void view_lab(int a) { cout<<"YOUR LAB WILL hold AT (dd/mm/yy) "<<record_zoology[a].get_dt(1)<<"/"

<<record_zoology[a].get_dt(2)<<"/"<<record_zoology[a].get_dt(3)<<en dl; cout<<"YOUR LAB WILL START AT "<<record_zoology[a].get_t(1)<<"hrs"<<endl; cout<<"YOUR LAB WILL END AT "<<record_zoology[a].get_t(2)<<"hrs"<<endl;

cout<<"TOTAL NUMBER OF STUDENTS IN YOUR LAB IS "<<record_zoology[a].get_c()<<endl; cout<<"ANIMALS AVAILABLE IN YOUR LAB ARE\n"<<endl; cout<<"NAME\t\t\tSPECIE\t\tNUMBERS"<<endl; for(int i=0;i<(animal_edit);i++) { cout<<zoology_animals[i].get_animal()<<setw(30- strlen(zoology_animals[i].get_animal()))

<<zoology_animals[i].get_specie();cout<<setw(18)<<zoology_animals[i ].get_numbers()<<endl; } cout<<"APPARATUS AVAILABLE IN YOUR LAB ARE\n"<<endl; cout<<"NAME\t\t\tTOTAL NUMBERS"<<endl; for(int i=0;i<(zoology_apparatus_edit);i++) { cout<<zoology_apparatus[i].get_name()<<setw(30- strlen(zoology_apparatus[i].get_name())) <<zoology_apparatus[i].get_count()<<endl; } } void view_STUDENT(int a) { cout<<"NAME OF STUDENT \n"<<endl<<student_zoology[a].get_comp(1)<<endl; cout<<"FATHER'S NAME \n"<<endl<<student_zoology[a].get_comp(2)<<endl; cout<<"TOTAL LAB SESSIONS \n"<<endl;cout<<student_zoology[a].get_comp(3)<<endl; cout<<"NO. OF LABS STUDENT ATTENDED \n"<<endl<<student_zoology[a].get_comp(4)<<endl; cout<<"AGGEREGATE OF STUDENT IN LAB \n"<<endl<<student_zoology[a].get_comp(5)<<endl; } int edit_STUDENT(int a) { flushall();

cout<<"NAME OF STUDENT \n";cin.getline(student_zoology[a].get_comp(1),100,'\n'); system("cls"); cout<<"FATHER'S NAME \n";cin.getline(student_zoology[a].get_comp(2),100,'\n'); system("cls"); cout<<"TOTAL LAB SESSIONS ";cin.getline(student_zoology[a].get_comp(3),100,'\n'); system("cls"); cout<<"NO. OF LABS STUDENT ATTENDED ";cin.getline(student_zoology[a].get_comp(4),100,'\n'); system("cls"); cout<<"AGGEREGATE OF STUDENT IN LAB";cin.getline(student_zoology[a].get_comp(5),100,'\n'); system("cls"); return 1;