You are on page 1of 8

#include <iostream>

#include <string>
#include <string.h>
using namespace std; //including required libraries,and beginning first class
class Classroom {
protected:
int* room_numb; //declaring required variables
int* building_no;
int* tot_seats;
int* tot_courses;
int* Start_time;
int* end_time;
string* name_of_courses; //bonus features
float* duration;
string* designated_teachers;

public: //declaring and defining the required functions


Classroom(int a) { //using constructors for default values
*room_numb = 0;
*building_no = 0;
*tot_seats = 0;
*tot_courses = 0;
*designated_teachers = "null";
*name_of_courses = "null";
*duration = 0;
*Start_time = 0;
*end_time = 0;

}
Classroom() { //using constructors for memory allocation
room_numb = new int;
building_no = new int;
tot_seats = new int;
tot_courses = new int;
designated_teachers = new string;
name_of_courses = new string;
Start_time = new int;
end_time = new int;

duration = new float;


;

}
~Classroom() { //destructor working in-line with constructor
delete[] room_numb;
delete[] building_no;
delete[] tot_seats;
delete[] tot_courses;
delete[] duration;
delete[] name_of_courses;
delete[] designated_teachers;
delete[] Start_time;
delete[] end_time;

} //setting and getting values of variables


void setroom_numb(int v) {
*room_numb = v;
}
int getroom_numb() {
return *room_numb;
}
void setStart_time(int v) {
*Start_time = v;
}
int getStart_time() {
return *Start_time;
}
void setend_time(int v) {
*end_time = v;
}
int getend_time() {
return *end_time;
}
void setbuilding_no(int n) {
*building_no = n;
}
int getbuilding_no() {
return *building_no;
}void settot_seats(int m) {
*tot_seats = m;
}
int gettot_seats() {
return *tot_seats;
}void settot_courses(int l) {
*tot_courses = l;
}
int gettot_courses() {
return *tot_courses;
}
void setduration(float l1) {
*duration = l1;
}

void setname_of_courses(string g) { //a similar scenario in case of string


arrays
*name_of_courses = g;

}
string getname_of_courses() {
return *name_of_courses;
}
void setdesignated_teachers(string x) {
*designated_teachers = x;

}
string getdesignated_teachers() {
return *designated_teachers;
}//making functions to print the data given by user
void print_class_info() {
cout << "The data entered regaurding the class is given below:" << endl
<< "Room Number : " << *room_numb << endl << "Building Number: " << *building_no;
cout << "Total Available Seats : " << *tot_seats << endl << "Duration
of one class: " << *duration << endl;
}
void Deetspc() {
cout << "The data of the selected class: " << endl << "Designated
Teachers: " << *designated_teachers << endl << "Start Time of Class: " <<
*Start_time << endl;
cout << "End time of the class: " << *end_time << endl;
}
void print_course_titles() {
cout << "The title of your course is: " << name_of_courses << endl;
}

};
class Lab {
protected:
int* room_numb; //declaring required variables
int* building_no;
int* tot_seats;
int* tot_courses;
//bonus features
int* duration; int* Start_time;
int* end_time;

string* designated_teachers;
string* course_titles;
int* no_of_lab_assistants;//extra details
public:
Lab(int a) { //using constructors for default inputs
*room_numb = 0;
*building_no = 0;
*tot_seats = 0;
*tot_courses = 0;
*duration = 0;
*Start_time = 0;
*end_time = 0;
*no_of_lab_assistants = 0;
*designated_teachers = "null";
*course_titles = "null";

}
Lab() {
room_numb = new int;
building_no = new int;
tot_seats = new int;
tot_courses = new int;
designated_teachers = new string;
course_titles = new string;
duration = new int;
Start_time = new int;
end_time = new int;

no_of_lab_assistants = new int;

}
~Lab() { //destructor working in-line with constructor
delete[] room_numb;
delete[] building_no;
delete[] tot_seats;
delete[] tot_courses;
delete[] duration;
delete[] no_of_lab_assistants;
delete[] designated_teachers;
delete[] course_titles;
delete[] Start_time; delete[] end_time;

}
void setStart_time(int v) {
*Start_time = v;
}
int getStart_time() {
return *Start_time;
}
void setend_time(int v) {
*end_time = v;
}
int getend_time() {
return *end_time;
}
void setroom_numb(int v) {
*room_numb = v;
}
int getroom_numb() {
return *room_numb;
}void setbuilding_no(int n) {
*building_no = n;
}
int getbuilding_no() {
return *building_no;
}void settot_seats(int m) {
*tot_seats = m;
}
int gettot_seats() {
return *tot_seats;
}void settot_courses(int l) {
*tot_courses = l;
}
int gettot_courses() {
return *tot_courses;
}void setduration(int l) {
*duration = l;
}
int getduration() {
return *duration;
}
void setcourse_titles(string t) { //a similar scenario in case of string
arrays
*course_titles = t;

}
string getcourse_titles() {
return *course_titles;
}
void setdesignated_teachers(string tq) { //a similar scenario in case of
string arrays
*designated_teachers = tq;
}
string getdesignated_teachers() {
return *designated_teachers;
}

void setno_of_lab_assistants(int v) { //extra functionality setter and getter


*no_of_lab_assistants = v;
}
int getno_of_lab_assistants() {
return *no_of_lab_assistants;

}void print_course_titles() {
cout << "The titles of courses are : " << course_titles << endl;
}
void Print_details() {
cout << "The data entered regaurding the lab is given below:" << endl
<< "Room Number : " << *room_numb << endl << "Building Number: " << *building_no;
cout << "Total Available Seats : " << *tot_seats << endl << "Duration
of one Lab: " << *duration << endl;

}
void Deetspc() {
cout << "The data of the selected Lab: " << endl << "Designated
Teachers: " << *designated_teachers << endl << "Start Time of Lab: " << *Start_time
<< endl;
cout << "End time of the Lab: " << *end_time << endl << "Number of Lab
Assistants: " << *no_of_lab_assistants << endl;
}

};

class University {
public:
Classroom mts;
Lab mts1;
Classroom mts3 (int u);
Lab mts4 (int u1);
int* TotalClasses;
int* TotalLabs;

public:
University() {
cout << "Welcome to the University" << endl;

}
University(int a) {
TotalClasses = new int;
TotalLabs = new int;
}
void setTotalClasses(int a) {
*TotalClasses = a;
}
int getTotalClasses() {
return *TotalClasses;
}
void setTotalLabs(int b) {
*TotalLabs = b;
}
int getTotalLabs() {
return *TotalLabs;
}
~University() {
delete[] TotalClasses;
delete[] TotalLabs;
} void print_tots() {
cout << "Total Classes: " << *TotalClasses << endl << "Total Labs: " <<
*TotalLabs << endl;
}
};

int main() { //the main function begins with variable declaration


University st; University kid; int a; int b; int num;
cout << "Do you wish to enter the details or access them:" << endl << "For
Accessing press 1" << endl << "for Entering press 2" << endl; cin >> num;
if (num == 2) {
cout << "This will Take a while so thank you for your time " << endl;
cout << "First enter all the information about the class rooms in your
dept. " << endl;
cout << "Enter the number of classes:" << endl;
cin >> a;
cout << "Enter the number of Labs :" << endl;
cin >> b; int *p1; int *p2; int *a6; int *b6; int *t; int *c; int
*d; string *e; string *f;
int *x1; int *x2; int *a9; int *b9; int *c3; int *d4; int *t1; int *t2;
string *e11; string *f8;
st.setTotalClasses(a);
st.setTotalLabs(b);
cout << "Now Enter the details of each class seperately: " << endl;
for (int i = 0; i < a; i++) {
cout << "Enter the number of Classroom : " << i + 1 << endl;
cin >> p1[i]; st.mts.setroom_numb(p1[i]);
cout << "Enter the Building Number where the class : " << i + 1
<< " is " << endl;
cin >> p2[i]; st.mts.setbuilding_no(p2[i]);
cout << "Enter the total number of seats in class : " << i + 1 <<
endl;
cin >> a6[i]; st.mts.settot_seats(a6[i]);
cout << "Enter the number of courses taught in the class : " << i
+ 1 << endl;
cin >> b6[i]; st.mts.settot_courses(b6[i]);
for (int y = 0; y < b6[i]; y++) {
cout << "Enter the Name of course number: " << y + 1 << "
of class " << i + 1 << endl;
cin >> e[y]; st.mts.setname_of_courses(e[y]);
cout << "Enter the Start Time of the course : " << e[y] <<
endl;
cin >> d[y]; st.mts.setStart_time(d[y]);
cout << "Enter the End time for course : " << e[y] << endl;
cin >> c[y]; st.mts.setend_time(c[y]);
cout << "Enter the name of the assigned teacher for
course : " << e[y] << endl;
cin >> f[y]; st.mts.setdesignated_teachers(f[y]);
}

cout << "Enter the overall duration for class : " << i + 1 <<
endl;
cin >> t[i]; st.mts.setduration(t[i]);
}
for (int j = 0; j < a; j++) {
cout << "Enter the number of Lab : " << j + 1 << endl;
cin >> x1[j]; st.mts1.setroom_numb(x1[j]);
cout << "Enter the Building Number where the lab : " << j + 1 <<
"is" << endl;
cin >> x2[j]; st.mts1.setbuilding_no(x2[j]);
cout << "Enter the total number of seats in Lab : " << j + 1 <<
endl;
cin >> a9[j]; st.mts1.settot_seats(a9[j]);
cout << "Enter the number of courses taught in the Lab : " << j +
1 << endl;
cin >> b9[j]; st.mts1.settot_courses(b9[j]);
for (int y = 0; y < b9[j]; y++) {
cout << "Enter the Name of course number: " << y + 1 << "
of class " << j + 1 << endl;
cin >> e11[y]; st.mts1.setcourse_titles(e11[y]);
cout << "Enter the Start Time of the course : " << e[y] <<
endl;
cin >> d4[y]; st.mts1.setStart_time(d4[y]);
cout << "Enter the End time for course : " << e[y] << endl;
cin >> c3[y]; st.mts1.setend_time(c3[y]);
cout << "Enter the name of the assigned teacher for
course : " << e[y] << endl;
cin >> f8[y]; st.mts1.setdesignated_teachers(f8[y]);
}
cout << "Enter the number of lab assistants for Lab: " << j + 1
<< endl;
cin >> t1[j]; st.mts1.setno_of_lab_assistants(t1[j]);

cout << "Enter the overall duration for Lab : " << j + 1 << endl;
cin >> t2[j]; st.mts1.setduration(t2[j]);
}
st.mts.print_class_info();
st.mts.print_course_titles();
for (int t = 0; t < a; t++) {
cout << "Specific details for class no: " << t + 1 << endl;
st.mts.Deetspc();
}
st.mts1.Print_details();
st.mts1.print_course_titles();
for (int t = 0; t < a; t++) {
cout << "Specific details for lab no: " << t + 1 << endl;
st.mts1.Deetspc();
}
}
else {
kid.mts3(1).print_class_info();
kid.mts3(1).print_course_titles();
kid.mts3(1).Deetspc();
kid.mts4(2).Print_details();
kid.mts4(2).print_course_titles();
kid.mts4(2).Deetspc();
}
system("pause");
return 0;
}

You might also like