-
Notifications
You must be signed in to change notification settings - Fork 0
/
Movie.cs
71 lines (59 loc) · 1.77 KB
/
Movie.cs
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
namespace ConsoleLinq;
public class Movie
{
#region Fields and properties.
/// <summary>
/// Rating in the kinopoisk list.
/// </summary>
public int Rating { get; set; }
/// <summary>
/// The name of the movie.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Year of release.
/// </summary>
public int YearOfProduction { get; set; }
/// <summary>
/// Country of manufacture.
/// </summary>
public string Country { get; set; }
/// <summary>
/// Rating of the film.
/// </summary>
public double RatingBall { get; set; }
/// <summary>
/// The name of the director.
/// </summary>
public string Director { get; set; }
#endregion
#region Methods for working with the file.
/// <summary>
/// Overriding the toString method.
/// </summary>
/// <returns> String representation of class properties. </returns>
public override string ToString()
{
return $"Name: {Name}, Rating: {Rating}, Year of production: {YearOfProduction}, " +
$"Country: {Country}, RatingBall: {RatingBall}, Director: {Director}.";
}
/// <summary>
/// Reading data from a file.
/// </summary>
/// <param name="line"> The path to the file. </param>
/// <returns> Returns a class with the specified parameters. </returns>
public static Movie ParseMovieCsv(string line)
{
var parts = line.Split(',');
return new Movie()
{
Rating = int.Parse(parts[0]),
Name = parts[1].Trim(),
YearOfProduction = int.Parse(parts[2]),
Country = parts[3].Trim(),
RatingBall = double.Parse(parts[4]),
Director = parts[5].Trim()
};
}
#endregion
}