test

Ruby code posted
created at 10 Mar 09:29

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class TopovskiNapad

  attr_accessor :razdalja_do_tarce
  attr_accessor :hitrost

  def initialize
    @razdalja_do_tarce = Random.rand(10...1000)
  end

  def vnesi_hitrost
    hitrost = preberi_vnos
    if(hitrost.to_i > 0 && hitrost.to_i < 299792458)
      @hitrost = hitrost
    else
      puts "vnesli ste neveljavno hitrost!"
    end
  end

  def preberi_vnos
    gets.chomp
  end

end
414 Bytes in 4 ms with coderay