C++. Please do not change the existing code. The instructions are in the image that is provided. Please zoom in or you can download the png file. Thank you! Time.cpp

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C++. Please do not change the existing code. The instructions are in the image that is provided. Please zoom in or you can download the png file. Thank you!

Time.cpp

#include "Time.h"

//Default Constructor

//Constructor with parameters

int Time::getHour() const { return hour; }
int Time::getMinute() const { return minute; }
int Time::getSecond() const { return second; }
void Time::setHour(int h) { hour = h; }
void Time::setMinute(int m) { minute = m; }
void Time::setSecond(int s) { second = s; }

int Time::timeToSeconds() const
{
    return (getSecond() + getMinute() * 60 + getHour() * 3600);
}

const Time Time::secondsToTime(int s) const
{
    int resultS = s % 60;
    s /= 60;
    int resultM = s % 60;
    s /= 60;
    int resultH = s % 24;
    return Time(resultH, resultM, resultS);
}

//toString

// +

// -

// <

// >

// ==

------

Time.h

#ifndef TIME
#define TIME

#include <string>

using namespace std;

class Time
{
private:
    int hour;
    int minute;
    int second;
    int timeToSeconds() const;
    const Time secondsToTime(int s) const;

public:
    Time();
    Time(int h, int m, int s);
    string toString() const;
    int getHour() const;
    void setHour(int h);
    int getMinute() const;
    void setMinute(int m);
    int getSecond() const;
    void setSecond(int s);
    const Time operator+(const Time &other) const;
    const Time operator-(const Time &other) const;
    bool operator<(const Time &other) const;
    bool operator>(const Time &other) const;
    bool operator==(const Time &other) const;
};

#endif

------

Date.cpp

#include "Date.h"

//Default Constructor

//Constructor with parameters

int Date::getDay() const { return day; }
int Date::getMonth() const { return month; }
int Date::getYear() const { return year; }
void Date::setDay(int h) { day = h; }
void Date::setMonth(int m) { month = m; }
void Date::setYear(int s) { year = s; }

//dateToDays

//daysToDate

//toString

// +

// -

// <

// >

// ==

------

Date.h

#ifndef DATE
#define DATE

#include <string>

using namespace std;

class Date
{
private:
    int day;
    int month;
    int year;
    int dateToDays() const;
    const Date daysToDate(int ndays) const;

public:
    Date();
    Date(int d, int m, int y);
    string toString() const;
    int getDay() const;
    void setDay(int d);
    int getMonth() const;
    void setMonth(int m);
    int getYear() const;
    void setYear(int y);
    const Date operator+(int ndays) const;
    const Date operator-(int ndays) const;
    bool operator<(const Date &other) const;
    bool operator>(const Date &other) const;
    bool operator==(const Date &other) const;
};

#endif

------

Event.cpp

------

Event.h

------

main.cpp

#include <iostream>
#include "Time.h"
#include "Date.h"
#include "Event.h"
using namespace std;

int main() {
   return 0;
}

Certainly! Below is an educational transcription of the image:

---

# Event Planning System: Classes Overview

In this project, you will create three classes for an event planning system: Time, Date, and Event. These classes will define how to describe when events occur and allow you to compare different times and dates.

## Time

### Purpose
The `Time` class manages a 24-hour cycle clock time. It covers the beginning of the day at 0:0:0 (Hour:Minute:Second) and ends at 23:59:59.

### Data Members
- `int sec`
- `int min`
- `int hour`

### Functions

#### Default Constructor
Initializes the time to a default value of 0:0:0.

#### Constructor
Accepts three integers representing hours, minutes, and seconds. If invalid values are provided (e.g., 63 minutes or -1 hours), the time is initialized to zero. Note that adjusting invalid input such as this is typically a topic addressed later in the semester.

Accepted ranges:
- Seconds: 0 to < 59
- Minutes: 0 to < 59
- Hours: 0 to < 23

#### Getters and Setters
Methods for accessing and modifying member variables. The getter method must be constant with its parameter as a constant reference.

#### toString
Returns a string describing the time in the format `hour:minute:second`.

*Example*

```cpp
Time time = Time(17, 59, 1);
cout << time.toString() << endl;
```

Outputs: `17:59:01`

#### TimeToSeconds
Private helper function that converts time into total seconds as an integer, used by comparison operators.

#### SecondsToTime
Private helper that converts an integer (seconds) to a Time object.

#### Operators
- **+ and -**: Support addition/subtraction of `Time` objects. If seconds exceed 59, convert to minutes.
  
  Example:
  ```cpp
  const Time operator+(const Time& other) const;
  const Time operator-(const Time& other) const;
  ```

- **< and >**: Supports comparisons, noting 0:0:0 as the smallest and 23:59:59 the largest.
  
  Example:
  ```cpp
  bool operator<(const Time& other) const;
  bool operator>(const Time& other) const;
Transcribed Image Text:Certainly! Below is an educational transcription of the image: --- # Event Planning System: Classes Overview In this project, you will create three classes for an event planning system: Time, Date, and Event. These classes will define how to describe when events occur and allow you to compare different times and dates. ## Time ### Purpose The `Time` class manages a 24-hour cycle clock time. It covers the beginning of the day at 0:0:0 (Hour:Minute:Second) and ends at 23:59:59. ### Data Members - `int sec` - `int min` - `int hour` ### Functions #### Default Constructor Initializes the time to a default value of 0:0:0. #### Constructor Accepts three integers representing hours, minutes, and seconds. If invalid values are provided (e.g., 63 minutes or -1 hours), the time is initialized to zero. Note that adjusting invalid input such as this is typically a topic addressed later in the semester. Accepted ranges: - Seconds: 0 to < 59 - Minutes: 0 to < 59 - Hours: 0 to < 23 #### Getters and Setters Methods for accessing and modifying member variables. The getter method must be constant with its parameter as a constant reference. #### toString Returns a string describing the time in the format `hour:minute:second`. *Example* ```cpp Time time = Time(17, 59, 1); cout << time.toString() << endl; ``` Outputs: `17:59:01` #### TimeToSeconds Private helper function that converts time into total seconds as an integer, used by comparison operators. #### SecondsToTime Private helper that converts an integer (seconds) to a Time object. #### Operators - **+ and -**: Support addition/subtraction of `Time` objects. If seconds exceed 59, convert to minutes. Example: ```cpp const Time operator+(const Time& other) const; const Time operator-(const Time& other) const; ``` - **< and >**: Supports comparisons, noting 0:0:0 as the smallest and 23:59:59 the largest. Example: ```cpp bool operator<(const Time& other) const; bool operator>(const Time& other) const;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Database connectivity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education