add solution for hw8

This commit is contained in:
JamesFlare1212
2025-04-07 17:10:37 -04:00
parent 9d1335bc18
commit 9fd32f72f6
6 changed files with 474 additions and 15 deletions

View File

@@ -0,0 +1,35 @@
#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++;
}