test

Ruby code posted
created at 10 Mar 09:42

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
24
25
26
27
28
29
30
31
32
33
34
35
class TopovskiNapad

  SVETLOBNA_HITROST = 299792458

  attr_accessor :razdalja_do_tarce
  attr_accessor :hitrost
  attr_accessor :kot

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

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

  def vnesi_kot
    kot = preberi_vnos
    if(kot.to_i > 0 && kot.to_i < 90)
      @kot = kot
    else
      puts "vnesli ste neveljaven kot!"
    end
  end

  def preberi_vnos
    gets.chomp
  end

end
645 Bytes in 4 ms with coderay