Advertisement
DanielDv99

SET_TEST

Sep 25th, 2017
2,721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 0.90 KB | None | 0 0
  1. class
  2.     TEST
  3.  
  4. create
  5.     make
  6.  
  7. feature
  8.     make
  9.             -- Initialising TEST
  10.         local
  11.             a, b: SET_INT
  12.             i : INTEGER
  13.             r : RANDOM
  14.         do
  15.             create a.empty_set
  16.             create b.empty_set
  17.             create r.make
  18.             from
  19.                 i := 0
  20.  
  21.             until
  22.                 i = 100
  23.             loop
  24.                 a.add ((r.double_item * 100).floor)
  25.                 r.forth
  26.                 b.add ((r.double_item * 100).floor)
  27.                 r.forth
  28.                 i := i + 1
  29.             end
  30.  
  31.             print("a: " + a.out)
  32.             IO.put_new_line
  33.  
  34.             print("b: " + b.out)
  35.             IO.put_new_line
  36.  
  37.             print("Union: " + a.union (b).out)
  38.             IO.put_new_line
  39.             print("Intersection: " + a.intersection (b).out)
  40.             IO.put_new_line
  41.             print("a - b: " + (a - b).out)
  42.             IO.put_new_line
  43.             print("b - a: " + (b - a).out)
  44.             IO.put_new_line
  45.             print("Cardinality of a: " + a.card.out)
  46.             IO.put_new_line
  47.             print("Cardinality of b: " + b.card.out)
  48.             IO.put_new_line
  49.             print("Is a a subset of b? " + a.is_subset (b).out)
  50.         end
  51.  
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement