verakochi

puts.rb

Mar 2nd, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.01 KB | None | 0 0
  1. class Cameleon2 # ���� �������� 2
  2.     def initialize #����������� ��������� ������
  3.         @size = 35;         #������
  4.         @color2 = "yellow";  #����
  5.         @weight = 11;       #���
  6.     end
  7.  
  8.     def feed        #����� ��������� ��������� �������� �� +2 � +1 ������� ����
  9.         @size += 2;            
  10.         @color2 = "Green";
  11.         @weight += 3;
  12.     end
  13.  
  14.     def walk        #����� �������� �������� ��������
  15.         @size -= 3;
  16.         @color2 = "white"
  17.         @weight -= 1;
  18.        
  19.     end
  20.  
  21.     #������ ��� ���������� ������������ ����������
  22.     def death
  23.  
  24.         case death2
  25.  
  26.         when @size <= 0
  27.             puts "�� ���� ��� ����("
  28.  
  29.         when @size >= 100
  30.             puts "�� ������, �� ������ ��������"
  31.  
  32.         when @weight <= 0
  33.             puts "�� ���� �� ������"
  34.  
  35.         else @weight >= 100
  36.             puts "�� ������"
  37.         end
  38.     end
  39.  
  40.     def life
  41.         puts " ������ ������� #{@size}, ���� ������� #{@color2},��� ������� #{@weight}"
  42.     end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment