1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LAB_6
- {
- public class Mebel : IComparable<Mebel>
- {
- public int Lp { get; set; }
- public string Nazwa { get; set; }
- public double Cena { get; set; }
- public override string ToString()
- {
- return $"Lp: {Lp,10} Nazwa: {Nazwa,-15} Cena: {Cena, 10:N2}";
- }
- public int CompareTo(Mebel other)
- {
- if(Lp<other.Lp) return -1 ;
- else if (Lp > other.Lp) return 1;
- else return 0 ;
- }
- }
- public class ByNazwaComp : IComparer<Mebel>
- {
- public int Compare(Mebel x, Mebel y)
- {
- return string.Compare(x.Nazwa, y.Nazwa);
- }
- }
-
- }
|