Meble.cs 731 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace LAB_6
  7. {
  8. public class Mebel : IComparable<Mebel>
  9. {
  10. public int Lp { get; set; }
  11. public string Nazwa { get; set; }
  12. public double Cena { get; set; }
  13. public override string ToString()
  14. {
  15. return $"Lp: {Lp,10} Nazwa: {Nazwa,-15} Cena: {Cena, 10:N2}";
  16. }
  17. public int CompareTo(Mebel other)
  18. {
  19. if(Lp<other.Lp) return -1 ;
  20. else if (Lp > other.Lp) return 1;
  21. else return 0 ;
  22. }
  23. }
  24. public class ByNazwaComp : IComparer<Mebel>
  25. {
  26. public int Compare(Mebel x, Mebel y)
  27. {
  28. return string.Compare(x.Nazwa, y.Nazwa);
  29. }
  30. }
  31. }