Does anyone know the solution to this problem? I am really lost. Thank you!
Create a class named DentalAppointment. Include fields for a patient’s data (use the Person class),
the date (using the Date class), the time (use the Time class), and the duration of the appointment
in minutes. Also include a field that contains the ending time of the appointment; this field will be
calculated based on the start time and the duration using the Time class function that adds minutes
to a Time object. The DentalAppointment constructor requires a first and last name, and a month,
day, year, hour, and minute for the appointment. Allow a DentalAppointment to be constructed
with or without an additional argument for appointment duration, and force the duration to 30
minutes when no argument is supplied. The constructor does not allow any appointment over 240
minutes. The constructor calculates the appointment ending time based on the start time and the
duration. Also include a display function for the DentalAppointment class. Write a main()function
that loops at least three times, prompting the user for DentalAppointment data and displaying all
the information. (Note, if you use the Person class display function, the zip code will be “X”; this is acceptable.)
Note: We already made a file in notepad, ClassData.txt
Am I gonna derived these classes to DentalAppointment? Thank you again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
class Person
{
private:
string lastName;
string firstName;
string zipCode;
public:
Person(string = "X", string = "X", string = "X");
void showPerson();
};
Person::Person(string last, string first, string zip)
{
lastName = last;
firstName = first;
zipCode = zip;
}
void Person::showPerson()
{
cout << firstName << " " << lastName << " lives in ZIP code " << zipCode << endl;
}
class Date
{
private:
int mo;
int day;
int year;
public:
Date(int = 1, int = 1, int = 2000);
void showDate();
};
Date::Date(int m, int d, int y)
{
mo = m;
day = d;
year = y;
}
void Date::showDate()
{
cout << mo << "/" << day << "/" << year << endl;
}
class Time
{
private:
int hours;
int minutes;
public:
Time(int, int = 0);
void add(int);
void display();
};
Time::Time(int hours, int mins)
{
const int MAXMINS = 59;
const int MAXHOURS = 23;
if(hours > MAXHOURS)
this->hours = MAXHOURS;
else
this->hours = hours;
if(mins > MAXMINS)
minutes = MAXMINS;
else
minutes = mins;
}
void Time::add(int mins)
{
const int MINSINHOUR = 60;
const int MAXHOURS = 23;
minutes += mins;
if(minutes >= MINSINHOUR)
{
int extraMinutes = minutes % MINSINHOUR;
hours += minutes / MINSINHOUR;
minutes = extraMinutes;
}
if (hours > MAXHOURS)
{
hours -= MAXHOURS;
}
}
void Time::display()
{
cout << "Time is " << hours << ":";
if(minutes >= 10)
cout << minutes << endl;
else
cout << "0" << minutes << endl;
}
|