Forum: Ruby Problem with beginner project

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7a82bbe2017c51afe60add05db63eca3?d=identicon&s=25 Coralie Rigaud (cocorigow)
on 2016-12-11 17:33
Hello,
I have a problem with the project 4 of Ruby for Kids. Could some one
please help me? I am trying to draw a rectangle but it is only printing
the top and bottom lines of the rectangle with nothing in the middle.
Thank you very much.

# Drawing a rectangle
puts "Welcome to Shapes"
print "How big is your rectangle? "
shape_size = gets
shape_size = shape_size.chomp
print "Outside letter: "
outside_letter = gets
outside_letter = outside_letter.chomp
print "Inside letter: "
inside_letter = gets
inside_letter = inside_letter.chomp
puts "About to draw a shape #{shape_size} big"
puts "using #{outside_letter}for the edge"
puts "and #{inside_letter} for the inside"
height = shape_size.to_i
width = shape_size.to_i
1.upto(height) do |row|
# Drawing Code goes here
if row  == 1
  puts outside_letter * width
elsif row == height
  puts outside_letter * width
else
  middle = inside_letter * (width - 2)
  puts
  "#{outside_letter}#{middle}#{outside_letter}"
end
end

This results in only displaying the top and bottom line of the rectangle
with no filling:
D:\development\project02>ruby shapes.rb
Welcome to Shapes
How big is your shape? 6
Outside letter: x
Inside letter: o
About to draw a shape 6 big
using xfor the edge
and o for the inside
xxxxxx


xxxxxx
D:\development\project02>
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2016-12-12 14:33
I think you have in the 'else' part the puts and the string to put in
different lines.

Aside from this, the program looks correct.
7a82bbe2017c51afe60add05db63eca3?d=identicon&s=25 Coralie Rigaud (cocorigow)
on 2016-12-12 18:12
Thank you so much :)
This topic is locked and can not be replied to.