Advertisement
klavi

nzn trigubai

Mar 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.03 KB | None | 0 0
  1. class Ckambarys
  2.  
  3. class Ckolba
  4.  class Cdalele
  5.   def initialize (x,y)
  6. i=0
  7.   @x=x
  8.   @y=y
  9.  
  10.   end #defo endas
  11. def Soulis (temp)
  12.   if temp<10
  13.     @dx=0
  14.     @dy=0
  15.   end #ifo endas
  16.  if ((temp>=10) and (temp<=20))  
  17.  @dx=1
  18.  @dy=1
  19.  
  20.  end #ifoendas
  21.   if temp >20
  22.     @dx=3
  23.     @dy=3
  24.   end#ifo endas
  25.   @x+=rand(-@dx..@dx)
  26.   @y+=rand(-@dy..@dy)
  27.   print "x=",@x," y=",@y,"\n"
  28.   end#defo endas
  29. end #calses endas
  30.   def initialize()
  31.  
  32.     @dalele=Cdalele.new(15,2)
  33.     @dalele.Soulis(0)
  34.  
  35.   end# defo endas
  36. def Sildimas(temp)
  37.  
  38.   @temp=temp
  39.   print " temperatura= ", @temp,"\n"
  40.   @dalele.Soulis(@temp)
  41.   end #defo endas
  42. end #clases endas
  43.  
  44. puts "------------------"
  45. puts "pirmosios kolbos šuoliai: "
  46. puts "------------------"
  47. for i in 1..5
  48.  
  49.  kolba1=Ckolba.new()
  50.  kolba1.Sildimas(20)
  51.  kolba1.Sildimas(300)
  52.  end #foro endas
  53.  puts "------------------"
  54.  puts "antrosios kolbos šuoliai: "
  55.  puts "------------------"
  56.  for i in 1..5
  57.  
  58.  kolba2=Ckolba.new()
  59.  kolba2.Sildimas(20)
  60.  kolba2.Sildimas(300)
  61.  end #foro endas
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement