Class: AnnRps::Comp

Inherits:
Object
  • Object
show all
Defined in:
lib/ann_rps.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeComp

Returns a new instance of Comp.



20
21
# File 'lib/ann_rps.rb', line 20

def initialize
end

Instance Attribute Details

#choiceObject (readonly)

Returns the value of attribute choice.



19
20
21
# File 'lib/ann_rps.rb', line 19

def choice
  @choice
end

Instance Method Details

#chooseObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ann_rps.rb', line 27

def choose
  num_choice = rand(1..3)
  if num_choice ==1
    puts "I chose Rock."
    @choice =  "r"
  elsif num_choice ==2
    puts "I chose Paper."
    @choice =  "p"
  else
    puts "I chose Scissors."
    @choice =  "s"
  end
end

#greeting(name) ⇒ Object



23
24
25
# File 'lib/ann_rps.rb', line 23

def greeting(name)
  puts "Hello #{name}, I'm Conrad.  Let's play a game of Rock Paper Scissors. "
end