CSc 250: Custom Tree

In this assignment, you will write a program that prints out a variets of text trees, with various sizes and characters.

Tree

Your program should accept three user inputs. The first is the single character to use for the leaves. The second is the single character to use for the trunk. Last, the user should enter SMALL, MEDIUM, or LARGE to specify how large of a tree to print out.

There are a few restrictions on these inputs. First of all, the “leaf character” and “trunk character” inputs must be exactly one character. If they are longer or shorter, a message should be displayed and the program ends (see examples later). Also, both must not be the empty space. If so, print a message and exit.

The error messages that should be used for each of these four cases are as follows:

You didn't type just one leaf character! That is invalid.
The leaf character cannot be a space! That is invalid.
You didn't type just one trunk character! That is invalid.
The trunk character cannot be a space! That is invalid.

Also, the size input must be SMALL, MEDIUM or LARGE. If it is not precicely one of those strings, print That is an invalid size. and then exit.

After ensuring that the inputs are correct, you can print out the appropriately sized tree. The SMALL, MEDIUM, and LARGE trees are to look like the ones below, respectively.

  ^
 ^^^
^^^^^
  X
   ^
  ^^^
 ^^^^^
^^^^^^^
   X
   X
    ^
   ^^^
  ^^^^^
 ^^^^^^^
^^^^^^^^^
    X
    X
    X

However, the characters used for the leaves and the trunk of the tree should change depending on what is selected by the user when typing in the input. Below are several example runs of the program.

Examples

what character to use for the leaves? ABC
what character to use for the trunk? X
You didn't type just one leaf character! That is invalid.
what character to use for the leaves? ^
what character to use for the trunk? 123
You didn't type just one trunk character! That is invalid.
what character to use for the leaves? W
what character to use for the trunk? T
SMALL, MEDIUM, or LARGE tree? SMALL
  W
 WWW
WWWWW
  T
what character to use for the leaves? 8
what character to use for the trunk? N
SMALL, MEDIUM, or LARGE tree? MEDIUM
   8
  888
 88888
8888888
   N
   N
what character to use for the leaves? $
what character to use for the trunk? Y
SMALL, MEDIUM, or LARGE tree? LARGE
    $
   $$$
  $$$$$
 $$$$$$$
$$$$$$$$$
    Y
    Y
    Y
what character to use for the leaves? R
what character to use for the trunk? G
SMALL, MEDIUM, or LARGE tree? smallll
That is an invalid size.

Name the file custom-tree.py.

Code Organization

Comments

All of your programs should be well-formatted and easy for the graders to read and comprehend. You should follow the style guidelines that we have discussed in class. Each program file should have a header comment at the top that has roughly the following format:

#
# Author: Student Name
# Description:
#    A short description of what this program does!
#

Submission and grading

This was assigned on January 19th, 2018. It is due on January 26th at 5:00pm.

Turn in each of the files described in the spec (1) to the assignment drop-box in D2L before the due date. Make sure to name the files exactly as this document specifies. In general, make sure to follow these instructions precisely.