Advertisement
Tolyamba

3

Jan 24th, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. class Money : Pair
  2.     {
  3.         ...
  4.         public override bool Equals(object obj)
  5.         {
  6.             Pair pair = obj as Pair;
  7.             return first == pair.First && second == pair.Second;
  8.         }
  9.     }
  10.  
  11.  
  12.  
  13. class Program
  14.     {
  15.         static void Main(string[] args)
  16.         {            
  17.             Pair p2 = new Pair(4, 5);
  18.             MyCollection mc1 = new MyCollection();
  19.             mc1.Add(5, p2);
  20.             Pair p3 = new Pair(8, 5);
  21.             bool check = mc1.ContainsValue(p3);
  22.             Money m1 = new Money(11, 22);
  23.             mc1.Add(4, m1);
  24.             check = mc1.ContainsValue(m1);
  25.             bool findKey = mc1.ContainsKey(11);
  26.             mc1.Print();
  27.             Console.WriteLine(check + " " + findKey);
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement