From 73d207cf55be7394edf1c383ec752d9e05c7fd29 Mon Sep 17 00:00:00 2001 From: YuliyaBond Date: Fri, 16 Mar 2018 00:29:02 +0300 Subject: [PATCH] corrected1 --- 2018/YuliyaBondareva/1/pascal_tree.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/2018/YuliyaBondareva/1/pascal_tree.rb b/2018/YuliyaBondareva/1/pascal_tree.rb index 6dd3a0b08..ba8e04266 100644 --- a/2018/YuliyaBondareva/1/pascal_tree.rb +++ b/2018/YuliyaBondareva/1/pascal_tree.rb @@ -26,16 +26,20 @@ def tree(number, base_number) puts 'Depth?' number = gets.chomp base_number = ENV['BASE'] -while number.to_i <= 0 do - puts 'depth must be positive. ' - puts 'Depth?' - number = gets.chomp - +if number.to_i <= 0 + loop do + puts 'depth must be positive. ' + puts 'Depth?' + number = gets.chomp + break if number.to_i > 0 + end end -while base_number.to_i <= 0 do - puts 'BASE must be positive. ' - puts 'BASE?' - base_number = gets.chomp +if base_number.to_i <=0 + loop do + puts 'BASE must be positive. ' + puts 'BASE?' + base_number = gets.chomp + break if base_number.to_i > 0 + end end tree(number.to_i, base_number.to_i) -