//this is the time.h #include<iostream> class Time{ public: Time(int hours, int
ID: 3661212 • Letter: #
Question
//this is the time.h
#include<iostream>
class Time{
public:
Time(int hours, int minutes, int seconds):hours(hours), minutes(minutes),seconds(seconds){}
void print(){std::cout<<hours<<":"<<minutes<<":"<<seconds<<std::endl;}
private:
int hours, minutes, seconds;
};
//this is the date.h
#include<iostream>
class Date{
public:
Date(int year, int month, int dom):year(year),month(month),dom(dom){}
void print(){std::cout<<year<<"/"<<month<<"/"<<dom<<std::endl;}
private:
int year, month, dom;
};
//this is the timestamp.h
#include<iostream>
#include"time.h"
#include"date.h"
class Timestamp{
public:
Timestamp(Date date, Time time);
Timestamp(int yr, int mth, int d, int h, int min, int sec);
void print(Date &date, Time &time){
date.print();
time.print();
}
private:
Date date;
Time time;
};
//the log.h
#include <iostream>
#include <string>
#include "timestamp.h"
class Log{
public:
Log(Timestamp timestamp, std::string message, int status){}
void print(Timestamp timestamp){std::cout<<"("<<timestamp.print()<<") "<<status<<": "<<message<<std::endl;}
private:
Timestamp timestamp;
std::string message;
int status;
};
Explanation / Answer
#ifndef TIME_H #define TIME_H #include using namespace std; class Time { private: int hour, minute, second; public: Time(); ~Time(); Time(int h, int m, int s); int getHour(); int getMinute(); int getSecond(); void setHour(int hour); void setMinute(int minute); void setSecond(int second); Time getTimeFromUser(Time b); bool validTime(Time a); void print24Hour(Time a); void print12Hour(Time b); }; #endif Schedule.h #ifndef SCHEDULE_H #define SCHEDULE_H #include #include "time.h" using namespace std; class Class { private: string name; int credits; bool majorRequirement; double avgGrade; string days; Time startTime; Time endTime; public: Class(); ~Class(); Class(string namae, int cred, bool majorReq, double avg, string day); //Mutate void setName(string h); void setCredits(int c); void setMajorRequirement(bool set); void setAvgGrade(double g); void setDays(string d); void getStartTimeFromUser(Time b); void getEndTimeFromUser(Time e); // Access string getName(); int getCredits(); bool getMajorRequirement(); double getAvgGrade(); string getDays(); Time& getStartTime(); Time& getEndTime(); }; #endif Schedule.cpp: Class::Class() { string name = ""; int credits = 0; bool majorRequirement = false; double avgGrade = 0.0; string days = ""; } Time::Time() { int hour = 0; int minute = 0; int second = 0; } Class::Class(string namae, int cred, bool majorReq, double avg, string day) { name = namae; credits = cred; majorRequirement = majorReq; avgGrade = avg; days = day; } Time::Time(int h, int m, int s) { second = s; minute = m; hour = h; } Time getTimeFromUser(Time b) { string time = ""; string hourS, minuteS, secondS = new string(); getline(cin,time); hourS = time.substr(0,2); minuteS = time.substr(3,2); secondS = time.substr(6,2); b.hour = atoi(hourS.c_str()); b.minute = atoi(minuteS.c_str()); b.second = atoi(secondS.c_str()); return b; } void getStartTimeFromUser(Time b) { startTime = getTimeFromUser(b); } void getEndTimeFromUser(Time e) { endTime = getTimeFromUser(e); } Other Mutators and Accessors here. Main is long. Here is the severely condensed version: #include #include #include #include #include "time.h" #include "schedule.h" using namespace std; int main() { // Expecting that variables are properly declared Class * klass = new Class[classcount]; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.