#!/usr/local/bin/ruby -w
# Author: js3104@cs.nyu.edu (Jack Shutzman)
# This program selects a random number  between 0 and 100.
# It asks the user to guess, and announces whether the guess
# is higher than its selection, lower or the same
# (the last option ends the game)

class Num
  include Comparable

  def <=>(guess)
    @a<=>guess
  end

end

if __FILE__ == $0
  r = rand 100
  puts "Please try to guess my number (between 0 and 100)", " "
  value=1 # Gets the comparison value, 0 means equals.
  while value != 0
    value=(gets.to_i<=>r)
    case value
      when -1 then puts "Too low"
      when  1 then puts "Too high"
    end
  end
  printf("You got it, %d is my number \n", r)
end

