Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Articles
- {
- class Program
- {
- public static void Main()
- {
- string[] input = Console.ReadLine().Split(", ", StringSplitOptions.RemoveEmptyEntries).ToArray();
- int num = int.Parse(Console.ReadLine());
- Article article = new Article(input[0], input[1], input[2]);
- for (int i = 0; i < num; i++)
- {
- string[] command = Console.ReadLine().Split(": ", StringSplitOptions.RemoveEmptyEntries).ToArray();
- if (command[0] == "Edit")
- {
- article.Edit(command[1]);
- }
- else if (command[0] == "ChangeAuthor")
- {
- article.ChangeAuthor(command[1]);
- }
- else if (command[0] == "Rename")
- {
- article.Rename(command[1]);
- }
- }
- Console.WriteLine(article.ToString());
- }
- public class Article
- {
- public Article(string title, string content, string author)
- {
- this.Title = title;
- this.Content = content;
- this.Author = author;
- }
- public object Title { get; set; }
- public object Content { get; set; }
- public object Author { get; set; }
- public void Edit(string newContent)
- {
- this.Content = newContent;
- }
- public void ChangeAuthor(string newAuthor)
- {
- this.Author = newAuthor;
- }
- public void Rename(string newTitle)
- {
- this.Title = newTitle;
- }
- public override string ToString()
- {
- return $"{this.Title} - {this.Content}: {this.Author}";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement