Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Article
- {
- public string Title { get; set; }
- public string Content { get; set; }
- public string Author { get; set; }
- public void Edit(string newContent)
- {
- Content = newContent;
- }
- public void ChangeAuthor(string newAuthor)
- {
- Author = newAuthor;
- }
- public void Rename(string newTitle)
- {
- Title = newTitle;
- }
- public override string ToString()
- {
- return $"{Title} - {Content}: {Author}";
- }
- public Article(string title, string content, string author)
- {
- Title = title;
- Content = content;
- Author = author;
- }
- }
- internal class Program
- {
- static void Main()
- {
- string[] articleInfo = Console.ReadLine().Split(new string[] { ", " }, StringSplitOptions.None);
- Article articleObject = new Article(articleInfo[0], articleInfo[1], articleInfo[2]);
- int commands = int.Parse(Console.ReadLine());
- for (int i = 0; i < commands; i++)
- {
- string[] input = Console.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None);
- switch (input[0])
- {
- case "Edit": articleObject.Edit(input[1]); break;
- case "ChangeAuthor": articleObject.ChangeAuthor(input[1]); break;
- case "Rename": articleObject.Rename(input[1]); break;
- }
- }
- Console.WriteLine(articleObject.ToString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement