Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
renaming variables in more description
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-bitbucket authored and anatoliliotych committed Jul 10, 2018
1 parent aa9e108 commit c7d1461
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
22 changes: 11 additions & 11 deletions 2396/1/koans/about_dice_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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'
Expand All @@ -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
16 changes: 8 additions & 8 deletions 2396/1/koans/triangle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit c7d1461

Please sign in to comment.