test
C
code posted
created at 10 Mar 09:59, updated at 30 Mar 20:10
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 36 37 38 39 |
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 izracun_razdalje_strela @razdalja_do_tarce = ((@hitrost ** 2) * (Math.sin(2 * @kot * Math::PI / 180) )/10) end def vnesi_hitrost hitrost = preberi_vnos if(hitrost.to_i > 0 && hitrost.to_i < SVETLOBNA_HITROST) @hitrost = hitrost.to_i 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.to_i else puts "vnesli ste neveljaven kot!" end end def preberi_vnos gets.chomp end end |
782 Bytes in 2 ms with coderay