using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LibrarySystem { // Books have a genre, of the following type: public enum Genre { Children, Fiction, NonFiction } // A book is a kind of item. public class Book : Item { // Instance variables. private string author; private string isbn; private Genre genre; // Constructor. public Book(string title, string author, string isbn, Genre genre) : base(title) { this.author = author; this.isbn = isbn; this.genre = genre; } public override bool CanBeBorrowedBy(Member member) { if (genre == Genre.Children) { // Children's books can only be borrowed by children. return member.Age <= 16; } else { // Other books can be borrowed by anyone. return true; } } public override string ToString() { return string.Format("{0}\n Additional book details: {1} {2} {3}.", base.ToString(), author, isbn, genre); } // Implementations of abstract methods/properties. public override DateTime? DateDueBack { get { if (dateBorrowed == null) { return null; } else { return dateBorrowed.Value.AddDays(21); } } } } }