namespace Model; public class Book : IEquatable { public long Id { get; private init; } public string Title { get => title; set => title = value ?? ""; } private string title = null!; public string Author { get => author; set => author = value ?? ""; } private string author = null!; public string Isbn { get => isbn; set => isbn = value ?? ""; } private string isbn = null!; public Person? Borrower { get; set; } public Book(long id, string title, string author, string isbn) { Id = id; Title = title; Author = author; Isbn = isbn; } public Book(string title, string author, string isbn) : this(0, title, author, isbn) { } public bool Equals(Book? other) { if (Id != 0) return Id == (other?.Id ?? 0); else return Title.Equals(other?.Title) && Author.Equals(other?.Author) && Isbn.Equals(other?.Isbn); } public override bool Equals(object? obj) { if(ReferenceEquals(obj, null)) return false; if(ReferenceEquals(obj, this)) return true; if(GetType() != obj.GetType()) return false; return Equals(obj as Book); } public override int GetHashCode() { if(Id != 0) return (int)(Id % 7879); else return Isbn.GetHashCode(); } public override string ToString() => $"{Id} - {Title} ({Isbn}) // {Author}"; }