tags:

views:

212

answers:

11

I’m teaching an entry-level C++ programming class. We only use iostream in the class (No GUI). It seems like students are not so excited to printout strings and numbers to their console. (Most students even never used the console before.) It is hard to motivate or convey the excitement of programming by showing strings in their console.

What would be a good and exciting console program that can be written by C++ beginners? I’m looking for something doable with basic C++ skill + a bit challenging + very exciting, which can motivate students to learn programming languages.

Any comments will be appreciated.

+2  A: 

When I taught an undergrad intro course, we did the Game of Fifteen in straight C as the third homework project. It's pretty well scoped, and it's a game, so there's some inherent motivation there.

quixoto
+1  A: 

I always enjoyed problems where there's a real world purpose for doing it. Something like calculating a mathematical equation, or a range of prime numbers. A lot of stuff on ProjectEuler would be good, I would think. Not everybody likes math (but then again, it's kind of a necessary thing for computer science!).

kcoppock
A: 

When I took C++ we had to replicate a Theseus and the Minotaur game. It lends well to outputting multiple lines to the console to form something "graphical" and it's easily based on a set of implemented rules.

Matthew PK
A: 

I've had to program a Tower of Hanoi game in the console before, I found that quite fun. It requires use of basic data structures, user input, checking for game end conditions so it would be good for a beginner I believe.

hydrogen
A: 

New programming students usually find graphical programs to be the most exciting.

It doesn't have to be anything really advanced, just being able to manipulate pixels and stuff should be enough to keep them interested. Making a simple graphic class around SDL should be ok. Maybe something like this:

int main()
{
   GraphicWindow graphic;
   graphic.setPixel(10,20,GraphicWindow::Red);
   graphic.idle();
}

Then you give out assignments like "implement a drawRect function" etc.

monoceres
+1  A: 

How about a system that generates a set of poker hands from a deck? While clearly defined, the intricacies of ensuring no duplicate cards etc, make it a good entry level challenge.

As an extension, you could have the system take an input as to whether you want to bet or fold, and effectively play a poker game.

Finally, a good design would allow them to switch the console for a gui front-end later on (e.g. intermediate class).

deworde
A: 

Instead of just printing to the screen you could make ascii animations.

girlygirl
I've lost the code somewhere, but I once implemented an aquarium with waving plants and swimming fish as ASCII art animation using curses to do the drawing. It ran amazingly well over a 2400 baud dialup.
RBerteig
+1  A: 

Introduce your students to pipes and filters. Create a useful utility that takes data from stdin and directs its output to stdout. Create another utility that does something else using that same protocol. Create a third utility. Demonstrate how robustly the utilities can work together.

For example, create a clone of the GNU head and tee utilities, and perhaps add a new utility called cap which capitalizes letters. Then demonstrate how you can get the first 3 lines of a text file capitalized and tee'd to a file and stdout. Next, demonstrate how you use the same utilities, without changing a single line of code, to take the first 5 lines of a file and output to the screen the capitalized letters and to a file the original letters.

wilhelmtell
+1  A: 

Back when I taught, I made an early project be an ATM machine.

Text-only interface, with basic operations like withdraw, deposit, query balance, transfer between accounts, etc.

It was something that everyone was already familiar with, it didn't take huge amounts of programming time, but it did help students feel like it was a practical and realistic program.

Other similar ideas would be a cash-register (handle refunds, coupons, items priced by the pound, sales-tax, store specials, etc, etc), or a cell-phone billing program (separate daytime, night, and weekend minutes, bill text messages, picture messages separately, etc).

abelenky
A: 

Perhaps a text-only version of the Lunar Lander game. You could do full ASCII art and animations (with ncurses, perhaps) as an advanced exercise, but even in a pure text form it can be interesting.

I recall playing the version that ran on the HP 67 calculator, and it was entertaining with only a seven segment display to work with.

I vaguely recall a version that probably ran on an ALTAIR 8800 written in MITS/Microsoft BASIC that used the leading part of the line to show height above ground as ASCII art, with your prompt for the next tick's burn at the right.

Another traditional choice would be to implement Hunt the Wumpus, or for the ambitious, Battleship.

RBerteig
A: 

One of my first programming class had a long homework about implementing a (reduced) Monopoly game.

You can use chained lists for the board. You can use Inheritance for board tiles. You need some logic to process players turns.

It was probably the first project I've done in CS that I could talk about to my non-tech friends and generate some interest.

Eric