using static System.Console;
using System.Collections.Generic;
var p1 = new Post(DateTime.Now, "Travelling to New Zealand", "I'm going to visit this wonderful country!", 12);
p1.AddComment(new Comment("Have a nice trip!"));
p1.AddComment(new Comment("Wow that's awesome!"));
var p2 = new Post(DateTime.Now, "Good night guys", "See you tomorrow", 5);
p2.AddComment(new Comment("Good night"));
p2.AddComment(new Comment("May the force be with you"));
public string Text { get; set; }
public Comment(string text) => Text = text;
public DateTime Moment { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int Likes { get; set; }
public List<Comment> Comments { get; set; } = new List<Comment>();
public Post(DateTime moment, string title, string content, int likes) {
public void AddComment(Comment comment) => Comments.Add(comment);
public void RemoveComment(Comment comment) => Comments.Remove(comment);
public override string ToString() {
var sb = new StringBuilder();
sb.AppendLine(Moment.ToString("dd/MM/yyyy HH:mm:ss"));
sb.AppendLine("Comments:");
foreach (Comment c in Comments) sb.AppendLine(c.Text);