Advertisement
themkss

Untitled

May 2nd, 2023
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5.  
  6. namespace LB4_V2
  7. {
  8.     /// <summary>
  9.     /// Data Class using Publication as its abstract class
  10.     /// </summary>
  11.     public class Journal : Publication, IComparable<Journal>, IEquatable<Journal>
  12.     {
  13.         public string ISBN { get; set; }
  14.         public int number { get; set; }
  15.         public int monthOfRelease { get; set; }
  16.  
  17.         /// <summary>
  18.         /// Constructor for Journal class
  19.         /// </summary>
  20.         /// <param name="name"></param>
  21.         /// <param name="type"></param>
  22.         /// <param name="publishingPlace"></param>
  23.         /// <param name="yearOfRelease"></param>
  24.         /// <param name="numberOfPages"></param>
  25.         /// <param name="edition"></param>
  26.         /// <param name="iSBN"></param>
  27.         /// <param name="number"></param>
  28.         /// <param name="monthOfRelease"></param>
  29.         public Journal(string name, string type, string publishingPlace, int yearOfRelease, int numberOfPages, int edition,
  30.             string iSBN, int number, int monthOfRelease) : base(name, type, publishingPlace, yearOfRelease, numberOfPages, edition)
  31.         {
  32.             ISBN = iSBN;
  33.             this.number = number;
  34.             this.monthOfRelease = monthOfRelease;
  35.         }
  36.  
  37.         /// <summary>
  38.         /// Implemented IComparable<Journal> interface
  39.         /// </summary>
  40.         /// <param name="other"></param>
  41.         /// <returns></returns>
  42.         public int CompareTo(Journal other)
  43.         {
  44.             if (this.yearOfRelease.CompareTo(other.yearOfRelease) != 0)
  45.             {
  46.                 return this.yearOfRelease.CompareTo(other.yearOfRelease);
  47.             }
  48.             else
  49.             {
  50.                 return this.monthOfRelease.CompareTo(other.monthOfRelease);
  51.             }
  52.         }
  53.  
  54.         /// <summary>
  55.         /// Implemented IEquatable<Journal> interface
  56.         /// </summary>
  57.         /// <param name="other"></param>
  58.         /// <returns></returns>
  59.         public bool Equals(Journal other)
  60.         {
  61.             if (this.ISBN.Equals(other.ISBN) && this.number == other.number && this.monthOfRelease == other.monthOfRelease)
  62.             {
  63.                 return true;
  64.             }
  65.             else
  66.             {
  67.                 return false;
  68.             }
  69.         }
  70.  
  71.         /// <summary>
  72.         /// Overridden ToString() method
  73.         /// </summary>
  74.         /// <returns></returns>
  75.         public override string ToString()
  76.         {
  77.             return String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", this.name, this.type, this.publishingPlace, this.yearOfRelease,
  78.                 this.numberOfPages, this.edition, this.ISBN, this.number, this.monthOfRelease);
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement