VladFomenko / RubyHW

0 stars 0 forks source link

Feedback HW 3 #10

Open MaksHostroushko opened 1 year ago

MaksHostroushko commented 1 year ago

Looks great! You did a big work Let's add some improvements

  1. On the first view this bit of code looks a little bit not understandable Please, don't use magic numbers. Save it to constants image

2.https://github.com/VladFomenko/RubyHW/blob/main/HW3/tamagochi/task2.rb#L81..L89 In this case, you can avoid if !. Just replace your code I mean

if hunger?
  puts 'I don\'t like vegetables(('
  change_main_params(health: 0, hunger: 0, thirst: 0, asleep: 0, time: 1)
  change_any_params(mood: 0, play: -2, love: rand(-3..-1))
else
  puts 'I don\'t want eat'
end
  1. https://github.com/VladFomenko/RubyHW/blob/main/HW3/tamagochi/task2.rb#L135...L141 You can tell_with_pet method inside if and else So, if you use it in both cases - just move it out of block

    if @all_actions.include?(your_method)
    send(@all_actions[your_method])
    else
    puts 'Oh, I don\'t know that :(' 
    end
    tell_with_pet
  2. unless rand(1..100) > 5 Please, try to don't use unless when you can use if For example, in this case, we can make our code more readable Please, fix it for all methods if rand(1..100) <= 5

VladFomenko commented 1 year ago

I didn't see it yesterday( but I read and corrected it now.

  1. Okay, I understand, I will work under it.
  2. Yes.
  3. Yes, rubocop spoke it, but I didn't understand it.
  4. Yes, I fixed all unless(three cases).