Files
CSCI-1200/hws/youtube_comments/comment.cpp
2025-04-07 17:12:14 -04:00

35 lines
904 B
C++

#include "comment.h"
// Constructor
Comment::Comment(std::string vid_id, std::string auth, std::string comm_id, int likes,
int replies, bool isReply, std::string parent_id, std::string pub_date,
std::string crawl_date, bool isOwner, std::string comm) {
video_id = vid_id;
author = auth;
comment_id = comm_id;
like_count = likes;
reply_count = replies;
is_reply = isReply;
parent_comment_id = parent_id;
published_date = pub_date;
crawled_date = crawl_date;
is_video_owner = isOwner;
comment = comm;
}
// Destructor - clean up all children
Comment::~Comment() {
for (size_t i = 0; i < children.size(); ++i) {
delete children[i];
}
}
// Add a child comment to this comment
void Comment::addChild(Comment* child) {
children.push_back(child);
}
// Like this comment
void Comment::like() {
like_count++;
}