Module: RandomGenerator

Defined in:
lib/randomgenerator.rb

Class Method Summary collapse

Class Method Details

.getRandomNumberObject



9
10
11
# File 'lib/randomgenerator.rb', line 9

def self.getRandomNumber
  return rand(20)
end

.getRandomOperationObject



4
5
6
7
# File 'lib/randomgenerator.rb', line 4

def self.getRandomOperation
  arr = ["+","-","*","+","-","*","+","-","*"]    
  return arr[rand(arr.size)]   
end

.operate(input1, input2, operation) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/randomgenerator.rb', line 13

def self.operate(input1,input2,operation)
  output = 0
  if(operation=="+")
    output = input1+input2
  elsif(operation=="-")
    output = input1-input2
  elsif(operation=="*")
    output = input1*input2
  end
  return output
end