Hello, I'm still new at classes and I was wondering how I would go about this program. I have most of the getters and setters so far but I don't have the getDate, getStandardTime, helper functions militaryToStandard, standardToMilitary, bool operator ==(const Appointment &first,
const Appointment &second)
Parameters:
• Appointment(); Default constructor
It should initialize the title to "N/A". The date should be initialized to 1, 1, and 1. The
time should be initialized to 0, and duration to 1.
• Appointment(string appData);
Add an appointment from a string in the format
"title|year|month|day|time|duration". Time is given in standard time
and duration is given in minutes. Leading and trailing spaces must be removed.
Example: " Meeting with Bob | 2021 |11 |23 |8:30 aM | 15 "
• string getTitle();
• int getYear();
• int getMonth();
• int getDay();
• int getTime(); //military time
• int getDuration();
• string getDate(); //return a date in the format 2021-11-23
• string getStandardTime();
• void setTitle(string newTitle);
• void setYear(int newYear);
• void setMonth(int newMonth);
• void setDay(int newDay);
• void setTime(int newTime); //military time
• void setDuration(int newDuration);
• void setDate(int newYear, int newMonth, int newDay);
In addition, the class must include the following helper functions:
• string militaryToStandard(int time);
Converts time from military (1830) to standard time ("6:30PM")
• int standardToMilitary(string time);
Converts standard time ("8:30PM") to military time (2030). It should handle lowerand upper-case letters.
returns the time in military time format (2030).
• bool operator ==(const Appointment &first,
const Appointment &second);
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
/**
* @file: appointment_main.cc
* @author: Enter your name
* @date: Enter the date
* @brief: Add Description
*/
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
class Appointment
{
public:
Appointment();
// Getters
string getTitle();
int getYear();
int getMonth();
int getDay();
int getTime(); // military time
int getDuration();
string getDate();
string getStandardTime();
// Setters
void setTitle(string newTitle);
void setYear(int newYear);
void setMonth(int newMonth);
void setDay(int newDay);
void setTime(int newTime); // military time
void setDuration(int newDuration);
void setDate(int newYear, int newMonth, int newDay);
private:
string title;
int year;
int month;
int day;
int time;
int duration;
} /// Appointment class
Appointment::Appointment()
{
title = "N/A";
time = 0;
duration = 1;
day = 1;
month = 1;
year = 1;
};
// Appointment C-tor
// function prototypes
int main(int argc, char const *argv[])
{
// test your class here
return 0;
} // main
// Add class functions here
void Appointment::setTitle(string newTitle)
{
if (newTitle = !"")
{
title = newTitle;
}
}
void Appointment::setYear(int newYear)
{
if (newYear > 1970)
{
year = newYear;
}
}
void Appointment::setMonth(int newMonth)
{
if (newMonth > 0 && newMonth <= 12)
{
newMonth = month;
}
}
void Appointment::setDay(int newDay)
{
if (newDay > 0 && newDay <= 31)
{
newDay = day;
}
}
void Appointment::setTime(int newTime)
{
if (newTime >= 0 && newTime < 2400)
{
newTime = time;
}
}
void Appointment::setDuration(int newDuration)
{
if (newDuration > 0)
{
newDuration = duration;
}
}
void Appointment::setDate(int newYear, int newMonth, int newDay)
{
newYear = year;
newMonth = month;
newDay = day;
}
string Appointment::getTitle()
{
return title;
}
int Appointment::getYear()
{
return year;
}
int Appointment::getMonth()
{
return month;
}
int Appointment::getDay()
{
return day;
}
int Appointment::getTime()
{
return time;
}
int Appointment::getDuration()
{
return duration;
}
string Appointment::getDate()
{
}
string Appointment::getStandardTime()
{
}
|