Dental Appointment program

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;
}
You appear to be the same person that posted this thread under a different username.
http://www.cplusplus.com/forum/beginner/172656/#msg858517

So where is your DentalAppointment class and main() ?

Am I gonna derived these classes to DentalAppointment

Use the following rules to determine whether to use inheritance (derive) or construction (member variable):
If the relationship is "IS A", then inheritance is usually appropriate.
If the relationship is "HAS A", the construction is appropriate.

So consider what you're told about DentalAppointment.
IS A DentalAppointment a Person? No. A DentalAppointment HAS A Person.
IS A DetnalAppointment a Date? No. A DentalAppointment HAS A Date.
etc.

So your initial attempt at DentalAppointment should look something like this:
1
2
3
4
5
6
7
8
class DentalAppointment
{   Person    person;
    Date        date;
    Time        start_time;
    Time        end_time;
public:
  //  I'll leave it to you to write the constructor and display functions.
};




Topic archived. No new replies allowed.