public IReadable CreateReadableItem(string[] data)
        {
            string itemType = data[0];
            string name = data[1];
            string publisher = data[2];
            int year = int.Parse(data[3]);
            Genres genre = GetGenre(data[4]);
            int counter = int.Parse(data[5]);
            int totalRatings = int.Parse(data[6]);
            int averageRating = int.Parse(data[7]);
            string authorOrIssue = data[8];

            Rating rating = new Rating(counter, totalRatings, averageRating);

            switch (itemType)
            {
                case "Book":
                    return new Book(name, publisher, year, genre, rating, authorOrIssue);
                case "Magazine":
                    return new Magazine(name, publisher, year, genre, rating, authorOrIssue);
                case "Newspaper":
                    return new Newspaper(name, publisher, year, genre, rating, authorOrIssue);
                default:
                    throw new LibraryCommonException(LibraryCommonException.ReadableTypeExceptionMessage);
            }
        }
 public ReadableItem(string name, string publisher, int year, Genres genre, Rating rating)
 {
     this.Name = name;
     this.Publisher = publisher;
     this.Year = year;
     this.Genre = genre;
     this.rating = rating;
     this.comment = new List<Comment>();
 }
Exemplo n.º 3
0
 public Book(string name, string publisher, int year, Genres genre, Rating rating, string author)
     : base(name, publisher, year, genre, rating)
 {
     this.Author = author;
 }
 public Newspaper(string name, string publisher, int year, Genres genre, Rating rating, string issue)
     : base(name, publisher, year, genre, rating)
 {
     this.Issue = issue;
 }
Exemplo n.º 5
0
 public Newspaper(string name, string publisher, int year, Genres genre, Rating rating, string issue)
     : base(name, publisher, year, genre, rating)
 {
     this.Issue = issue;
 }