From c7d14611f6abf627bf2ef2c46f28d3acfa5a01e7 Mon Sep 17 00:00:00 2001 From: ilya-bitbucket Date: Tue, 10 Jul 2018 23:00:40 +0300 Subject: [PATCH] renaming variables in more description --- 2396/1/koans/about_dice_project.rb | 22 +++++++++++----------- 2396/1/koans/triangle.rb | 16 ++++++++-------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/2396/1/koans/about_dice_project.rb b/2396/1/koans/about_dice_project.rb index 9ddb9c870..390be65a4 100644 --- a/2396/1/koans/about_dice_project.rb +++ b/2396/1/koans/about_dice_project.rb @@ -3,10 +3,10 @@ # Implement a DiceSet Class here: # class DiceSet - attr_reader :values + attr_reader :meanings def roll(size) - @values = Array.new(size) { rand(1..6) } + @meanings = Array.new(size) { rand(1..6) } end end @@ -29,9 +29,9 @@ def test_rolling_the_dice_returns_a_set_of_integers_between_1_and_6 dice = DiceSet.new dice.roll(5) - assert dice.values.is_a?(Array), 'should be an array' - assert_equal 5, dice.values.size - dice.values.each do |value| + assert dice.meanings.is_a?(Array), 'should be an array' + assert_equal 5, dice.meanings.size + dice.meanings.each do |value| assert value >= 1 && value <= 6, "value #{value} must be between 1 and 6" end end @@ -43,8 +43,8 @@ def test_rolling_the_dice_returns_a_set_of_integers_between_1_and_6 def test_dice_values_do_not_change_unless_explicitly_rolled dice = DiceSet.new dice.roll(5) - first_time = dice.values - second_time = dice.values + first_time = dice.meanings + second_time = dice.meanings assert_equal first_time, second_time end @@ -56,10 +56,10 @@ def test_dice_values_should_change_between_rolls dice = DiceSet.new dice.roll(5) - first_time = dice.values + first_time = dice.meanings dice.roll(5) - second_time = dice.values + second_time = dice.meanings assert_not_equal first_time, second_time, 'Two rolls should not be equal' @@ -79,9 +79,9 @@ def test_you_can_roll_different_numbers_of_dice dice = DiceSet.new dice.roll(3) - assert_equal 3, dice.values.size + assert_equal 3, dice.meanings.size dice.roll(1) - assert_equal 1, dice.values.size + assert_equal 1, dice.meanings.size end end diff --git a/2396/1/koans/triangle.rb b/2396/1/koans/triangle.rb index 69da859de..93f4a6a33 100644 --- a/2396/1/koans/triangle.rb +++ b/2396/1/koans/triangle.rb @@ -20,10 +20,10 @@ # This method smells of :reek:UncommunicativeVariableName # This method smells of :reek:TooManyStatements # This method smells of :reek:FeatureEnvy -def select_type_triangle(per_a, per_b, per_c) - if per_a == per_b && per_b == per_c +def select_type_triangle(side_a, side_b, side_c) + if side_a == side_b && side_b == side_c :equilateral - elsif per_a == per_b || per_a == per_c || per_b == per_c + elsif side_a == side_b || side_a == side_c || side_b == side_c :isosceles else :scalene @@ -36,14 +36,14 @@ def select_type_triangle(per_a, per_b, per_c) # This method smells of :reek:UncommunicativeVariableName # This method smells of :reek:TooManyStatements # This method smells of :reek:FeatureEnvy -def triangle(per_a, per_b, per_c) - s = (per_a + per_b + per_c) / 2.0 +def triangle(side_a, side_b, side_c) + s = (side_a + side_b + side_c) / 2.0 # the following must be positive to be a valid triangle - ok = (s - per_a) * (s - per_b) * (s - per_c) + ok = (s - side_a) * (s - side_b) * (s - side_c) - raise TriangleError if per_a <= 0 || per_b <= 0 || per_c <= 0 || ok <= 0 + raise TriangleError if side_a <= 0 || side_b <= 0 || side_c <= 0 || ok <= 0 - select_type_triangle(per_a, per_b, per_c) + select_type_triangle(side_a, side_b, side_c) end # Error class used in part 2. No need to change this code.