-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_Articles_2_0
54 lines (50 loc) · 1.61 KB
/
03_Articles_2_0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Linq;
using System.Collections.Generic;
namespace _03_Articles_2_0
{
class Program
{
static void Main()
{
int SubmmitnArticles = int.Parse(Console.ReadLine());
List<Article> articles = new List<Article>();
for (int i = 1; i <= SubmmitnArticles; i++)
{
string[] input = Console.ReadLine().Split(", ");
Article article = new Article(input[0], input[1], input[2]);
articles.Add(article);
}
string ExecuteOperation = Console.ReadLine();
switch (ExecuteOperation)
{
case "title":
articles = articles.OrderBy(x => x.Title).ToList();
break;
case "content":
articles = articles.OrderBy(x => x.Content).ToList();
break;
case "author":
articles = articles.OrderBy(x => x.Author).ToList();
break;
}
Console.WriteLine(string.Join(Environment.NewLine, articles));
}
}
class Article
{
public string Title { get; set; }
public string Content { get; set; }
public string Author { get; set; }
public Article(string title, string content, string author)
{
this.Title = title;
this.Content = content;
this.Author = author;
}
public override string ToString()
{
return $"{this.Title} - { this.Content}: { this.Author}";
}
}
}