Advertisement
PhilDrummer

Assignment_7 04 DIE.e

Nov 19th, 2014
1,208
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class
  2.     DIE
  3.  
  4. create
  5.     roll
  6.  
  7. feature -- Access
  8.  
  9.     Face_count: INTEGER = 6
  10.             -- Number of faces.
  11.  
  12.     face_value: INTEGER
  13.             -- Latest value.
  14.  
  15. feature -- Basic operations
  16.  
  17.     roll
  18.             -- Roll die.
  19.         do
  20.             random.forth
  21.             face_value := random.bounded_item (1, Face_count)
  22.         end
  23.  
  24. feature {NONE} -- Implementation
  25.  
  26.     random: V_RANDOM
  27.             -- Random sequence.
  28.         once
  29.             create Result
  30.         end
  31.  
  32. invariant
  33.     face_value_valid: face_value >= 1 and face_value <= Face_count
  34. end
Advertisement
RAW Paste Data Copied
Advertisement