TheBulgarianWolf

Article

Jan 3rd, 2021
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Articles
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Enter your input: ");
  10.             string input = Console.ReadLine();
  11.             string[] inputInfo = input.Split(", ");
  12.             Article article = new Article(inputInfo[0], inputInfo[1], inputInfo[2]);
  13.             Console.WriteLine("Enter the number of operations you want to conduct(1-3): ");
  14.             int operations = int.Parse(Console.ReadLine());
  15.             if(operations == 1)
  16.             {
  17.                 article.Edit();
  18.             }
  19.             else if(operations == 2)
  20.             {
  21.                 article.Edit();
  22.                 article.ChangeAuthor();
  23.             }
  24.             else
  25.             {
  26.                 article.Edit();
  27.                 article.ChangeAuthor();
  28.                 article.ChangeTitle();
  29.             }
  30.  
  31.             Console.WriteLine($"{article.Content} - {article.Author} - {article.Title}");
  32.         }
  33.     }
  34.  
  35.     class Article
  36.     {
  37.         public Article(string title, string content, string author)
  38.         {
  39.             Title = title;
  40.             Content = content;
  41.             Author = author;
  42.         }
  43.         public string Title { get; set; }
  44.         public string Content { get; set; }
  45.         public string Author { get; set; }
  46.  
  47.         public void Edit()
  48.         {
  49.             Console.Write("Edit: ");
  50.             string newContent = Console.ReadLine();
  51.             Content = newContent;
  52.         }
  53.  
  54.         public void ChangeAuthor()
  55.         {
  56.             Console.Write("Author: ");
  57.             string newAuthor = Console.ReadLine();
  58.             Author = newAuthor;
  59.         }
  60.  
  61.         public void ChangeTitle()
  62.         {
  63.             Console.Write("Title: ");
  64.             string newTitle = Console.ReadLine();
  65.             Title = newTitle;
  66.         }
  67.  
  68.     }
  69. }
  70.  
Add Comment
Please, Sign In to add comment