Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace LB4_V2
- {
- /// <summary>
- /// Data class which uses Publication as its abstract class
- /// </summary>
- public class Book : Publication, IComparable<Book>, IEquatable<Book>
- {
- public string ISBN { get; set; }
- public string author { get; set; }
- /// <summary>
- /// Constructor for this class
- /// </summary>
- /// <param name="name"></param>
- /// <param name="type"></param>
- /// <param name="publishingPlace"></param>
- /// <param name="yearOfRelease"></param>
- /// <param name="numberOfPages"></param>
- /// <param name="edition"></param>
- /// <param name="iSBN"></param>
- /// <param name="author"></param>
- public Book(string name, string type, string publishingPlace, int yearOfRelease, int numberOfPages, int edition,
- string iSBN, string author) : base(name, type, publishingPlace, yearOfRelease, numberOfPages, edition)
- {
- this.ISBN = iSBN;
- this.author = author;
- }
- /// <summary>
- /// Implemented IEquatable<Book> interface
- /// </summary>
- /// <param name="other"></param>
- /// <returns></returns>
- public bool Equals(Book other)
- {
- if (this.ISBN.Equals(other.ISBN) && this.author.Equals(other.author))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// Implemented IComparable<Book> interface
- /// </summary>
- /// <param name="other"></param>
- /// <returns></returns>
- public int CompareTo(Book other)
- {
- return this.yearOfRelease.CompareTo(other.yearOfRelease);
- }
- /// <summary>
- /// Overridden ToString() method
- /// </summary>
- /// <returns></returns>
- public override string ToString()
- {
- return String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", this.name, this.type, this.publishingPlace, this.yearOfRelease,
- this.numberOfPages, this.edition, this.ISBN, this.author);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement