#ifndef Time_h #define Time_h #include #include using namespace std; class myTime{ private: int hours; int minutes; int seconds; string AM_PM; public: myTime(); myTime(int a,int b,int c,string e); void sethours(int a); void setminutes(int b); void setseconds(int c); int gethours(); int getminutes(); int getseconds(); string getAM_PM(); void print(); void ticktack(); }; #endif #include "time.h" myTime::myTime(){ cout<<"hours:"<>hours; if(hours<1 || hours>12) hours=12; cout<<"minutes:"<>minutes; if(minutes<0 || minutes>59) minutes=0; cout<<"seconds:"<>seconds; if(seconds<0 || seconds>59) seconds=0; cout<<"is it AM or PM:"<>x; if(x=="AM"||x=="PM") AM_PM=x; else AM_PM="AM"; } myTime::myTime(int a,int b,int c,string e){ sethours(a); setminutes(b); setseconds(c); AM_PM=e;} void myTime::sethours(int a){ if(a<1||a>12) a=12; else hours=a; } void myTime::setminutes(int b){ if(b<0||b>59) b=0; else minutes=b; } void myTime::setseconds(int c){ if(c<0||c>59) c=0; else seconds=c; } int myTime::gethours(){ return hours; } int myTime::getminutes(){ return minutes; } int myTime::getseconds(){ return seconds; } string myTime::getAM_PM(){ return AM_PM; } void myTime::ticktack(){ seconds++; if(seconds==60) { minutes++; seconds=0; } if(minutes==60) { hours++; minutes=0; } if(hours==13) { hours=1; } if((hours==12 && minutes==0 && seconds==0)&&(AM_PM=="AM")){ AM_PM="PM"; } elseif((hours==12 && minutes==0 && seconds==0)&&(AM_PM=="PM")){ AM_PM="AM"; } } void myTime::print(){ cout<
Implement class student that represents a student object as follows.
Use separate implementation, with different header to store the class declaration.
Data members:
1) An object of type myTime called RegTime.
-
2) String variable the represent the name of the student.
-
3) A student ID that should be incremented automatically according to the number of objects
created so far.
Member Functions:
4) The class should have a default and two parameterized constructors; the first parameterized constructor take five parameters: 3 integers to represent the day, month, and year of the mytime object, and 2 strings to represent “am/pm” and the name; the second constructor should take two parameters: a Time object and a string.
5) The class should be able to print to the standard output information about itself.
Q2:
Implement class course defined as follows.
Use separate implementation, with different header to store the class declaration.
-
1) The class should encapsulate information about:
- the name of course (String),
- creation time of the course (myTime) ,
- number of students enrolled in the course (integer) (must be greater than 1), if the user provides avalue less than 1, assume the default value. - An array of Students of maximum size of 10.
-
2) The class should contain parameterized constructor .
-
3) The class should contain getters for each of the name, creation date and the number of
students.
-
4) The class should contain setter for the creation date.
-
5) The class should be able to print to the standard output all of its details.Q3:
-
1) define Non member function called findMaxStudents, that takes two course objects and returns the name of the course with the highest number of students enrolled in it.
-
2) define Non member function called DelayCourseTime, that that takes a course object. It prints its creation time. Then add extra 5 second to that Time and then set the new Time back to the course object and then reprint the time again.
In the main function, do the following:
-
1) define two course objects, fill the data needed for the objects as follow:
the first object: name is c++ lab, and have 3 students.
the second object: name is Java lab, and have 4 students.
Create the necessary time objects and student arrays needed for the object creation. -
2) call the function findMaxStudents for the two course objects to print the name of the course with the highest number of students enrolled in it.
-
call the function DelayCourseTime using first course object.
sample output in the attachment image
-
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images