Problem with beginner project

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>

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.

Thank you so much :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs