Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Monday, January 18, 2016

Interesting Console Program for C++ beginners

Interesting Console Program for C++ beginners


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.

Answer by Ben Zotto for Interesting Console Program for C++ beginners


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.

Answer by kcoppock for Interesting Console Program for C++ beginners


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!).

Answer by Matthew for Interesting Console Program for C++ beginners


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.

Answer by hydrogen for Interesting Console Program for C++ beginners


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.

Answer by monoceres for Interesting Console Program for C++ beginners


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.

Answer by deworde for Interesting Console Program for C++ beginners


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).

Answer by girlygirl for Interesting Console Program for C++ beginners


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

Answer by wilhelmtell for Interesting Console Program for C++ beginners


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.

Answer by abelenky for Interesting Console Program for C++ beginners


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).

Answer by RBerteig for Interesting Console Program for C++ beginners


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.

Answer by Eric for Interesting Console Program for C++ beginners


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.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.