Lessons on Drawing a Rocket

It was on March 12th of 2015, my second week at C4Q Access-code 2.0. It was my journey in progress to become a Mobile Application Developer. This part of the program was named unit-0 where we learn Java 7. In the two last weeks, we have learned the basics of Java (primitive types, reference types, if statements, while loops ,for loops, etc). Our class was given an assignment to try and draw a ASCII rocket that would scale to whichever number we liked. We were given 3 pictures of size increments that we would use as reference for building our own.

This was the first rocket I drew. It was very nice and simple (in my opinion more visually appealing =P). All I used was nested for loops to create the head, body, and line. All I did was ask for the size of rocket that the user wanted. Then afterwards, just take their input as size(int) and use the methods that I created like this:

drawHead(size);
drawLine(size);
drawBody(size);
drawLine(size);
drawBody(size);
drawLine(size);
drawHead(size);

While showing a classmate my drawRocket assignment a Teaching Assistant, Mr. Davis Roman came and took a look. He made a comment that while it looked nice but does it show that I have grasped the logic of the rockets in the demo? It was a waking call and I realized that if I was working for company and over simplified every project like this, I would get fired in no time. This 3rd roket looked nothing like the demo and was so easy that even a 3 year old without any programming experience could make in a day.

I started taking this assignment more seriously and studied the rocket to make adjustments to capture the logic. An example, was the head’s scaling:

Size 1=1 row (1 space, 1 forward slash, 2 stars, 1 backwards slashes, and 1 return)
Size 2=3 row (4 spaces, 3 forward slashes, 2 stars, 3 backward slashes, and 1 return)
Size 3=5 row (6 spaces, 5 forward slashes, 2 stars, 5 backward slashes, and 1 return)

This was the code in making the head. row is size+size-1. Space starts at 1 so that it will always be one more than the forward slashes except the first one. The logic in java the for the space is size+size-row so I get the inverse increment relationship with rows. (I forgot to rename bottom fslash to bslash, but to be honest I could have just named it slash) The amount of slashes will simply follow the rows by setting the for loop to stop at row size. The stars don’t change so it is not in a for loop.

This is my final draw rocket

drawHead(size);
drawLine(size);
drawBodyU(size);
drawBodyD(size);
drawLine(size);
drawBodyU(size);
drawBodyD(size);
drawLine(size);
drawHead(size);

I know that this rocket does not look exact like the demo. But I have the logic down. All I have to do is swap the second bodyU and bodyD. I just like this appearance better. This was a valuable lesson that I have learn 2 important things that will benefit me forever.

  1. The is a fine line between creativity and plain incompetence.
  2. Simply drawing out the logic will make the job much easier.

This is the 2nd week of my 9 month journey in C4Q to learn programming. It is also the very beginning of my Mobile Application Development career. I have at least learned to draw a rocket.