Giter Club home page Giter Club logo

rubyhw's Introduction

  • 👋 Hi, I’m @DmytroOnopa
  • 👀 I’m interested in ...
  • 🌱 I’m currently learning ...
  • 💞️ I’m looking to collaborate on ...
  • 📫 How to reach me ...

rubyhw's People

Contributors

dmytroonopa avatar

Stargazers

 avatar

Watchers

 avatar

rubyhw's Issues

Add at least 1 more actions

Должно быть 10-20 методов, которые позволяли бы совершать с животным определенные действия, например, "покормить", "положить спать", "поиграть".

class Fish

Need to standardize the code

Run "rubocop -a" to update auto-correctable cases then run "rubocop" to see cases needed to resolve by hand

flipper.rb:39:5: C: Style/GuardClause: Use a guard clause (return unless @hunger_indicator > 100) instead of wrapping the code inside a conditional expression.
    if @hunger_indicator > 100
    ^^
flipper.rb:50:5: C: Style/GuardClause: Use a guard clause (return unless @mood > 100) instead of wrapping the code inside a conditional expression.
    if @mood > 100
    ^^
flipper.rb:51:14: C: [Correctable] Layout/SpaceAroundOperators: Operator = should be surrounded by a single space.
      @heals =  100 - 50
             ^
flipper.rb:51:15: C: [Correctable] Layout/ExtraSpacing: Unnecessary spacing detected.
      @heals =  100 - 50
              ^
flipper.rb:62:5: C: Style/GuardClause: Use a guard clause (return unless @fish_wc.negative?) instead of wrapping the code inside a conditional expression.
    if @fish_wc.negative?
    ^^
flipper.rb:72:5: C: Style/GuardClause: Use a guard clause (return unless @fish_mana > 50) instead of wrapping the code inside a conditional expression.
    if @fish_mana > 50
    ^^
flipper.rb:83:5: C: Style/GuardClause: Use a guard clause (return unless @health >= 100) instead of wrapping the code inside a conditional expression.
    if @health >= 100
    ^^
flipper.rb:89:7: C: Naming/MethodName: Use snake_case for method names.
  def DisplayingInformation
      ^^^^^^^^^^^^^^^^^^^^^
flipper.rb:104:7: C: [Correctable] Style/IdenticalConditionalBranches: Move @fish_mana -= 5 out of the conditional.
      @fish_mana -= 5
      ^^^^^^^^^^^^^^^
flipper.rb:106:7: C: [Correctable] Style/IdenticalConditionalBranches: Move @fish_mana -= 5 out of the conditional.
      @fish_mana -= 5
      ^^^^^^^^^^^^^^^
flipper.rb:115:5: C: Style/GuardClause: Use a guard clause (return unless @fish_mana < 0) instead of wrapping the code inside a conditional expression.
    if @fish_mana < 0
    ^^
flipper.rb:115:8: C: [Correctable] Style/NumericPredicate: Use @fish_mana.negative? instead of @fish_mana < 0.
    if @fish_mana < 0
       ^^^^^^^^^^^^^^
flipper.rb:123:7: C: Naming/MethodName: Use snake_case for method names.
  def TimePeriod
      ^^^^^^^^^^
flipper.rb:149:7: C: [Correctable] Layout/CommentIndentation: Incorrect indentation detected (column 6 instead of 7).
      #@health -= 5
      ^^^^^^^^^^^^^
flipper.rb:149:7: C: [Correctable] Layout/LeadingCommentSpace: Missing space after #.
      #@health -= 5
      ^^^^^^^^^^^^^
flipper.rb:150:5: C: [Correctable] Layout/IndentationWidth: Use 2 (not 3) spaces for indentation.
       puts 'Low level mana!'
    ^^^
flipper.rb:163:5: C: Style/GuardClause: Use a guard clause (return unless @health <= 0) instead of wrapping the code inside a conditional expression.
    if @health <= 0
    ^^
flipper.rb:173:1: C: Naming/VariableName: Use snake_case for variable names.
menuSelect = gets.chomp.to_i
^^^^^^^^^^
flipper.rb:174:7: C: Naming/VariableName: Use snake_case for variable names.
while menuSelect != 0
      ^^^^^^^^^^
flipper.rb:176:8: C: Naming/VariableName: Use snake_case for variable names.
  case menuSelect
       ^^^^^^^^^^
flipper.rb:180:5: C: Naming/VariableName: Use snake_case for variable names.
    menuSelect = gets.chomp.to_i
    ^^^^^^^^^^
flipper.rb:184:5: C: Naming/VariableName: Use snake_case for variable names.
    menuSelect = gets.chomp.to_i
    ^^^^^^^^^^
flipper.rb:188:5: C: Naming/VariableName: Use snake_case for variable names.
    menuSelect = gets.chomp.to_i
    ^^^^^^^^^^
flipper.rb:192:5: C: Naming/VariableName: Use snake_case for variable names.
    menuSelect = gets.chomp.to_i
    ^^^^^^^^^^
flipper.rb:196:5: C: Naming/VariableName: Use snake_case for variable names.
    menuSelect = gets.chomp.to_i
    ^^^^^^^^^^
flipper.rb:200:5: C: Naming/VariableName: Use snake_case for variable names.
    menuSelect = gets.chomp.to_i
    ^^^^^^^^^^
flipper.rb:204:5: C: Naming/VariableName: Use snake_case for variable names.
    menuSelect = gets.chomp.to_i
    ^^^^^^^^^^
flipper.rb:207:5: C: Naming/VariableName: Use snake_case for variable names.
    menuSelect = gets.chomp.to_i
    ^^^^^^^^^^
flipper.rb:210:5: C: Naming/VariableName: Use snake_case for variable names.
    menuSelect = gets.chomp.to_i

# frozen_string_literal: true

Prevent methods call duplication

You can move fish.DisplayingInformation and menuSelect = gets.chomp.to_i under the block case when end so they will run each time

FE:

while menuSelect != 0
  case menuSelect
  when 1
    fish.feed
  when 2
    fish.pvp
  when 3
    fish.toilet
  when 4
    fish.mana_reg
  when 5
    fish.healing
  when 6
    fish.sleeping
  when 7
    fish.bathe
  when 8
    fish.DisplayingInformation
  when 9
    fish.help
  else
    break
  end
  fish.DisplayingInformation unless [8, 9].include?(menuSelect)
  menuSelect = gets.chomp.to_i
end

fish.DisplayingInformation()

menuSelect = gets.chomp.to_i

You don't need "map" method

puts "Без нечетных чисел: #{array.map.select(&:even?)}"

puts "Те числа, которые без остатка делятся на 3: #{array.map.select { |el| (el % 3).zero? }}"

puts "Без повторяющихся чисел: #{array.map.uniq}"

puts "Без нечетных чисел: #{array.map.select(&:even?)}"

puts "Те числа, которые без остатка делятся на 3: #{array.map.select { |el| (el % 3).zero? }}"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.