Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Ckolba
- class Cdalele
- ##----------------------------------------------------------------
- def initialize (x,y)
- i=0
- @x=x
- @y=y
- end
- ##----------------------------------------------------------------
- def Soulis (temp)
- if temp<10
- @dx=0
- @dy=0
- end
- if ((temp>=10) and (temp<=20))
- @dx=1
- @dy=1
- end
- if temp>20
- @dx=3
- @dy=3
- end
- @x+=rand(-@dx..@dx)
- @y+=rand(-@dy..@dy)
- if(temp>=10)
- print "x=",@x," y=",@y,"\n"
- end
- end
- end
- ##----------------------------------------------------------------
- def initialize()
- @dalele=Cdalele.new(0,0)
- @dalele.Soulis(0)
- end
- ##----------------------------------------------------------------
- def Sildimas(temp,k)
- print "Temperatura= ", temp,"\n"
- if (temp<10)
- print "Visos #{k} daleliu nepajudejo"
- else
- for j in 1..k
- @temp=temp
- @k=k
- print "#{j}-os daleles pozicija: "
- @dalele.Soulis(@temp)
- end
- end
- end
- end
- ##----------------------------------------------------------------
- for i in 1..2
- t=rand(0..30)
- print "#{i}-a kolba","\n"
- print "Pradine daleles pozicija kolboje: "
- kolba=Ckolba.new()
- kolba.Sildimas(t,20)
- print "\n"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement