Docsity

Class Physics Lab-Object Oriented Programming-C Language Codes, Exercises of Object Oriented Programming

Toggle sidebar
bg1
#include"chem_lab.h"
class PHYSICS_lab
{
stu student_physics[100];
float ph;
int record_no,ap_edit,b;
rec_handler record_physics[100];
attendant physics_attendant;
location physics_lab_location;
capacity physics_lab_capacity;
timings physics_lab_timings;
apparatus physics_apparatus[20];
public:
PHYSICS_lab():record_no(0),ap_edit(0){}
int physics_menu()
{
int a;
while(1)
{
q9:
cin.clear();
cout<<"PRESS \n ";
cout<<" 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";
flushall();
cin>>ph;
system("cls");
a=ph;
if(ph-a>0)
{
cout<<"Not a valid option \n";
flushall();
goto q9;
}
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:
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

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

#include"chem_lab.h" class PHYSICS_lab { stu student_physics[100]; float ph; int record_no,ap_edit,b; rec_handler record_physics[100]; attendant physics_attendant; location physics_lab_location; capacity physics_lab_capacity; timings physics_lab_timings; apparatus physics_apparatus[20]; public: PHYSICS_lab():record_no(0),ap_edit(0){} int physics_menu() { int a; while(1) { q9: cin.clear(); cout<<"PRESS \n "; cout<<" 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"; flushall(); cin>>ph; system("cls"); a=ph; if(ph-a>0) { cout<<"Not a valid option \n"; flushall(); goto q9; } 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: A: cin.clear(); cout<<"ENTER YOUR TOKEN NUMBER\n"; cin>>b; system("cls"); if(b<1||b>record_no) { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto A ; } view_lab(b); break; case 5: C: cin.clear(); cout<<"ENTER REGISTRATION NUMBER OF STUDENT\n"; cin>>b; system("cls"); if(b<0||b>99) { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto C ; } view_STUDENT(b); break; case 6: return 1; break; } } } void get_rec() {

cout<<"^^^^^^^^^^^^^^^^^^^^^LAB LOCATION^^^^^^^^^^^^^^^^^^^^^"<<endl<<endl; cout<<"COLLEGE NAME------ "<<physics_lab_location.g1_r()<<endl; cout<<"LAB NAME---------- "<<physics_lab_location.g2_r()<<endl<<endl; cout<<"^^^^^^^^^^^^^^^^^^^^^LAB TIMINGS^^^^^^^^^^^^^^^^^^^^^^"<<endl<<endl; cout<<"OPENING TIME------ "<<physics_lab_timings.g_rec()<<"hrs"<<endl; cout<<"CLOSING TIME------ "<<physics_lab_timings.g1_rec()<<"hrs"<<endl;

flushall(); cin.getline(physics_attendant.get_rc(),100); system("cls"); cout<<"enter experiance of attendant\n"; flushall(); cin.getline(physics_attendant.gt_rc(),100); system("cls"); cout<<"enter registration number of attendant\n"; flushall(); cin.getline(physics_attendant.g_rc(),100); system("cls"); break; case 2: cout<<"enter name of college\n"; flushall(); cin.getline(physics_lab_location.g1_r(),100,'\n'); system("cls"); flushall(); cout<<"enter name of LAB\n"; flushall(); cin.getline(physics_lab_location.g2_r(),100); system("cls"); break; case 3: H: cin.clear(); cout<<"enter number of student_physics which can be accumudated in lab\n"; int k; cin>>k; system("cls"); if(k>0) { physics_lab_capacity.get_students()=k; } else { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto H ; } 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) {

physics_lab_timings.g_rec()=k; } else { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto F ; } G: cin.clear(); cout<<"enter closing time of lab\n"; flushall(); k=0; cin>>k; system("cls"); if(k>=physics_lab_timings.g_rec() && k<=2400) { physics_lab_timings.g1_rec()=k; } else { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto G ; } break; case 5: E: cin.clear(); cout<<"PRESS 1 FOR NEW APPARATUS PRESS 2 FOR EDITING APPARATUS\n"; cin>>c; if(c!=1 && c!=2) { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto E ; } if(c==1) { cout<<"ENTER NAME OF APPARATUS\n"; flushall(); cin>>physics_apparatus[ap_edit].get_name(); system("cls"); flushall(); int g; C: cin.clear(); cout<<"ENTER NUMBER OF APPARATUS\n"; cin>>g; flushall();

system("cls"); } break; case 6: D: cin.clear(); cout<<"ENTER REGISTRATION NUMBER OF STUDENT\n"; flushall(); cin>>b;system("cls"); if(b<0||b>99) { cout<<"Not a Valid choice \n" ; cin.clear () ; cin.ignore (INT_MAX,'\n') ; goto D ; } edit_STUDENT(b); case 7: return 1; break; } } } void lab_session() { cout<<"ENTER DATE OF LAB SESSION\n"; flushall(); cin>>record_physics[0].get_dt(1); system("cls"); cout<<"ENTER MONTH OF LAB SESSION\n"; flushall(); cin>>record_physics[0].get_dt(2); system("cls"); cout<<"ENTER YEAR OF LAB SESSION\n"; flushall(); cin>>record_physics[0].get_dt(3); system("cls"); cout<<"ENTER NO. OF STUDENTS YOU WANT TO HAVE A LAB SESSION\n"; flushall(); cin>>record_physics[0].get_c(); system("cls"); cout<<"ENTER STARTING TIME OF LAB IN hrs (FORM 0100-2400)\n"; flushall(); cin>>record_physics[0].get_t(1); system("cls"); cout<<"ENTER ENDING TIME OF LAB IN hrs (FORM 0100-2400)\n"; flushall(); cin>>record_physics[0].get_t(2);system("cls"); comparison(); } void comparison() { int i;

for(i=1;i<100;i++) { if( (record_physics[i].get_dt(1)==record_physics[0].get_dt(1))&&(record_physi cs[i].get_dt(2)==record_physics[0].get_dt(2))

&&(record_physics[i].get_dt(3)==record_physics[0].get_dt(3))&&(reco rd_physics[i].get_t(1)==record_physics[0].get_t(1))

&&(record_physics[i].get_t(2)==record_physics[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_physics[0].get_c()>physics_lab_capacity.get_students()) || (record_physics[0].get_t(1)<physics_lab_timings.g_rec()) || (record_physics[0].get_t(2)>physics_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_physics[record_no].get_dt(1)=record_physics[0].get_dt(1);

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

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

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

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

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

system("cls"); }

};