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>
- /// abstract class Publication
- /// </summary>
- public abstract class Publication : IComparable<Publication>, IEquatable<Publication>
- {
- public string name { get; set; }
- public string type { get; set; }
- public string publishingPlace { get; set; }
- public int yearOfRelease { get; set; }
- public int numberOfPages { get; set; }
- public int edition { get; set; }
- /// <summary>
- /// Constructor for abstract Publication 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>
- protected Publication(string name, string type, string publishingPlace, int yearOfRelease, int numberOfPages, int edition)
- {
- this.name = name;
- this.type = type;
- this.publishingPlace = publishingPlace;
- this.yearOfRelease = yearOfRelease;
- this.numberOfPages = numberOfPages;
- this.edition = edition;
- }
- /// <summary>
- /// Overridden method ToString();
- /// </summary>
- /// <returns></returns>
- public override string ToString()
- {
- return String.Format("{0},{1},{2},{3},{4},{5}", this.name, this.type, this.publishingPlace, this.yearOfRelease, this.numberOfPages, this.edition);
- }
- /// <summary>
- /// Implemented IComparable<Publication> interface
- /// </summary>
- /// <param name="other"></param>
- /// <returns></returns>
- public int CompareTo(Publication other)
- {
- return this.yearOfRelease.CompareTo(other.yearOfRelease);
- }
- /// <summary>
- /// Implemented IEquatable<Publication> interface
- /// </summary>
- /// <param name="other"></param>
- /// <returns></returns>
- public bool Equals(Publication other)
- {
- if(this.name.Equals(other.name) && this.type.Equals(other.type) && this.publishingPlace.Equals(other.publishingPlace)
- && this.yearOfRelease == other.yearOfRelease && this.numberOfPages == other.numberOfPages && this.edition == other.edition)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement