# Ryan Martin
# macid: abcd123
# student number: #######
# August 8, 2011
#
# This is a solution for Marked Assignment 3 (Lab 07) on Monday.

def makeEdgeRow(w, c):
    '''Returns a string of length w made of c.'''
    
    line = c * w
    return line

def makeRow(w, c):
    '''Returns a string of length w with c at 0 and w and an empty interior.'''
    
    line = c + ' ' * (w - 2) + c
    return line

def makeBox(w, h, p):
    '''Returns a list of lines that form a box of width w and height h made of the pattern p.'''

    result = []
    result.append(makeEdgeRow(w, p[0]))

    for i in range(1, h - 1):
        result.append(makeRow(w, p[i]))

    result.append(makeEdgeRow(w, p[h - 1]))

    return result

'''
Design Question

There are several advantages to writing makeBox using
makeEdgeRow and makeRow:

1) Readability improves, since less lines of code are
involved (of course, poor naming conventions could still
cause problems).

2) Modularity improves, since each function is suited
to a specific task. makeRow and makeEdgeRow can be
re-used to create other shapes later.

3) Maintainability improves, due to separation of
concerns. If many functions depended on makeRow, and
a change was to be made, then fewer lines of code 
need to be changed. This also naturally helps with 
debugging for the same reasons.

Testing Report

Test: 1 for function makeEdgeRow
Input: [(5, '@')]
Expected Output: ['@@@@@']
Actual Output: ['@@@@@']
Result:Pass

Test: 1 for function makeRow
Input: [(6, '$')]
Expected Output: ['$    $']
Actual Output: ['$    $']
Result: Pass

Test: 1 for fuction makeBox
Input: [(8, 5, 'ATEST')]
Expected Output: [['AAAAAAAA', 'T      T', 'E      E', 'S      S', 'TTTTTTTT']]
Actual Output; [['AAAAAAAA', 'T      T', 'E      E', 'S      S', 'TTTTTTTT']]
Result: Pass
'''