I took a break from using Ruby Monk yesterday. Instead, I spent the day writing little practice programs and looking for new learning materials. I wrote a program for each Class that used all the methods I’ve learned for each Class. These programs didn’t produce anything meaningful, it was really just testing what I’ve learned. I also wrote a couple little programs that combined different Classes and methods as well as loops and branching. These little programs actually did something meaningful.
I found a great tutorial to complement Ruby Monk. It’s Chris Pine’s “Learn to Program.” It’s also a book if you prefer a hard copy. While Ruby Monk gives a quick and dirty run down, “Learn to Program” gives a pretty complete picture & explains some of the logic behind certain features. The combination of the two is great: Ruby Monk to introduce new ideas & procedures, “Learn to Program” to develop those ideas.
“Learn to Program” also gives practice ideas at the end of chapters. I love this as sometimes I have a hard time thinking of a fun way to apply what I’ve learned. I especially like the “Deaf Grandma” exercise. I had a lot of fun making the program longer and more complex than what was suggested.
After finishing the “Deaf Grandma” exercise, I decided to program a fortune teller, like a Magic 8 Ball. Instead of the answers being the normal “Outlook looks good,” I tried to make the answers funny like “Not if you’re wearing that.” I used a random number generator in conjunction with a bunch of if..else branches to create the different responses. Right now, it has 10 responses, but I could add as many responses as I wanted. I’d sort of like to make it a huge program with 100 responses so you rarely get the same answer twice. I doubt I’ll do it though, I don’t think I could think of that many snarky responses!