-
Notifications
You must be signed in to change notification settings - Fork 0
/
Post.hpp
135 lines (98 loc) · 3.57 KB
/
Post.hpp
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
/****************************************************************************************************************************
Title : Post.hpp
Author : Modified by Kasaf Shah
Description : header/interface for Post class
Date Modified : 12/09/2022
****************************************************************************************************************************/
#ifndef POST_
#define POST_
#include <iostream>
#include <string>
#include <time.h>
class Post {
public:
enum priority{
LOW,
MEDIUM,
HIGH
};
/**
Parameterized constructor.
@param : The title of the post (a string)
@param : The body content of the post (a string)
@param : The username of the Account that added this post (a string)
@post : Sets the title, body and username to the value of the parameters
It will also generate the current time and store it
*/
Post(std::string title, std::string body, std::string username);
/**
@return : the title of the Post
*/
std::string getTitle() const;
/**
@param : a reference to title of the Post
@post : sets the private data member to the value of the parameter
*/
void setTitle(const std::string& title);
/**
@return : the body of the Post
*/
std::string getBody() const;
/**
@param : a reference to body of the Post
@post : sets the private data member to the value of the parameter
*/
void setBody(const std::string& body);
/*
Accessor Function
@return : username associated with this Post
*/
std::string getUsername() const;
/*
Mutator Function
@param : a reference to the username associated with this Post
@post : sets the private data member to the value of the parameter
*/
void setUsername(const std::string& username);
/**
@post : prints the time the Post was created to the standard output as asctime(localtime(&time_stamp_))
*/
void getTimeStamp() const;
/*
Mutator Function
@post : sets the private data member to the current time
*/
void updateTimeStamp();
void virtual displayPost() = 0;
/*
@param : The Post object to compare
@return : true if this Post's username is less than the parameter
Post username, false otherwise
*/
bool operator<(const Post& object)const;
/*
@param : The Post object to compare
@return : true if this Post's username is greater than the
parameter Post username, false otherwise
*/
bool operator>(const Post& object)const;
//@post : increments the likes_ private member
void like();
//@return : the value of the likes_ private member
int getLikes();
/*@priority : a priority value
@post : sets the priority_id_ to the value of the parameter*/
void setPriority(const priority);
// @return : the value of the priority_id_ data member
priority getPriority();
private:
std::string post_title_;
std::string post_body_;
time_t time_stamp_;
std::string username_;
int likes_; //an integer that keeps track of the number of likes the post received
/*a variable of enum type 'priority': {LOW, MEDIUM, HIGH}, by default
MEDIUM. This enum is defined within the public section of the Post class.*/
priority priority_id_=MEDIUM;
};//end Post
#endif