Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- using System.Numerics;
- using System.Collections.Generic;
- using System.Linq;
- namespace Article
- {
- class Program
- {
- public static void Article(List<string> list, int n)
- {
- string title = list[0];
- string content = list[1].Trim();
- string author = list[2].Trim();
- Article article = new Article(title, content, author);
- for (int i = 0; i < n; i++)
- {
- string[] tokens = Console.ReadLine().Split(':', StringSplitOptions.RemoveEmptyEntries);
- string command = tokens[0].ToLower(); // trim that
- string replacer = tokens[1].Trim();
- if (command == "Edit".ToLower())
- {
- article.Edit(replacer);
- }
- else if (command == "ChangeAuthor".ToLower())
- {
- article.ChangeAuthor(replacer);
- }
- else if (command == "Rename".ToLower())
- {
- article.Rename(replacer);
- }
- }
- Console.WriteLine(article.ToString());
- }
- static void Main()
- {
- List<string> list = Console.ReadLine().Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();
- int n = int.Parse(Console.ReadLine());
- Article(list, n);
- }
- }
- public 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 changer)
- {
- this.Content = changer;
- }
- public void ChangeAuthor(string changer)
- {
- this.Author = changer;
- }
- public void Rename(string changer)
- {
- this.Title = changer;
- }
- public override string ToString()
- {
- return $"{this.Title} - {this.Content}: {this.Author}";
- }
- }
- } // .
Advertisement
Add Comment
Please, Sign In to add comment