Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 14th, 2018 57 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. class OrangeTree
  2.   def initialize()
  3.     @wysokosc= 0
  4.     @wiek = 0
  5.     @iloscOwocow = 0
  6.   end
  7.  
  8.   def height()
  9.     print "Wysokosc drzewa wynosi " + @wysokosc.to_s + "\n"
  10.   end
  11.  
  12.   def oneYearPasses()
  13.     @wiek+=1
  14.     @wysokosc += rand(1.0..10.0).round(2)
  15.     if @wiek<=5
  16.       @iloscOwocow=0
  17.     elsif @wiek < 50
  18.       @iloscOwocow += (@wiek-5)
  19.     end
  20.   end
  21.  
  22.   def pickAnOrange()
  23.     if @iloscOwocow == 0
  24.       print "Nie ma juz owocow do zerwania w tym roku\n"
  25.     else
  26.       print "Pomarancza jest pyszna\n"
  27.       @iloscOwocow-=1
  28.     end
  29.   end
  30.  
  31.   def countTheOranges()
  32.     print "Na drzewie wisi " + @iloscOwocow.to_s + " pomarancze\n"    
  33.   end
  34.  
  35.   def toString()
  36.     if @wiek <= 50
  37.       print "Drzewo pomaranczowe - wiek: "+ @wiek.to_s + ", wysokosc: "+ @wysokosc.to_s + "m\n"
  38.     else
  39.       print "Drzewo pomaranczowe - drzewo jest martwe\n"
  40.     end
  41.   end
  42. end
  43.  
  44. orange_tree = OrangeTree.new
  45.  
  46. orange_tree.oneYearPasses
  47. orange_tree.toString
  48. orange_tree.pickAnOrange
  49. 7.times {orange_tree.oneYearPasses}
  50. orange_tree.toString
  51. orange_tree.pickAnOrange
  52. orange_tree.countTheOranges
  53. orange_tree.pickAnOrange
  54. orange_tree.countTheOranges
  55. 55.times {orange_tree.oneYearPasses}
  56. orange_tree.toString
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top