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