Advertisement

looking for tasks to practice c++

Started by December 21, 2002 02:24 AM
5 comments, last by deal 21 years, 10 months ago
i have been learning c++ using.... Sams Teach Yourself C++ in 21 Days Second Edition - (yeh i know the title is bullshit, takes years/always learning new stuff etc...i read some posts here before i started learning hehe) so far i have went throught the following chapters Day 1 Getting Started Day 2 The Parts of a C++ Program Day 3 Variables and Constants Day 4 Expressions and Statements Day 5 Functions Day 6 Basic Classes Day 7 More Program Flow found most of it pretty easy, but im concerned about moving onto the second 'week' had a quick read and it looks a little tougher - pointers, references etc. so before i move on i thought i would spend a little time reinforcing the stuff in the first week (so i can concentrate upon learning the new stuff without having to go back to anything i missed/not sure about) the book includes a small number of simple exercises, but no where near enough (imo) so after trying to think of my own tasks to do and running out of ideas ( lol leave the creative stuff to the artists :D ) i thought i would come here and ask if anyone can direct me to some exersizes or something similar. thanx. [edited by - deal on December 21, 2002 5:57:26 AM]
make a class thats like a celebrety.
you can use functions to retreat his age, length, balablablabla.
display those things with a class that like a reporter.


.lick

[edited by - Pipo DeClown on December 21, 2002 7:50:20 AM]
Advertisement
Hey, I used the exact same book to learn c++ from!
I started with that book, and let me tell you it
was great!

I had the same fear as you, and I just kept trying new things
with the stuff i had learned in week 1.

Before i moved on I made sure I completely understood the
week in review program (the one with the rectangle maker).

Then just like you, i peeked into the second week and everything seemed tougher.

But i just kept going with it, rereading parts i didn''t understand and doing ALL the exercises. Hey, I agree with you about the lack of exercises, but like i said before, try make your own.

While reading through the second chapter i used everything i had learned so far and made some simple text games.

In fact I still haven''t finished the book as I got completely lost in some of the week 3 topics, but I''m gonna come back to it soon... (just finishing up a text game).

I ain''t no pro but this is what helped me.

chacha
i think im ready for pointers, btw i love classes
Create a class date. This class should track years and days. There should be some way to set the date, and some way to move to the next day. Make sure that whenever a date is set or changed that it is still a valid date.

Take leap years into account. Including all of the wierd rules.

Add a function to get the current month. Since you are using julian days and years, you will have to convert it. Leap years also affect this.

Add functions to get the current year and the current julian day.

-----------------------------------

Create two classes encrypt and decrypt. I shall describe encrypt, but decrypt is just the mirror image. Encrypt needs to be initialized with a date object (above) and a string (be sure to use ''string'' s rather than ''char*'' s as there is less room for wierd errors.

Encrypt then has one function called ''getNextLetter''. This function will encrypt the next letter in the string (starting at the first one) and return that encryption. Symbols and special characters are skipped, only letters, spaces, and newlines are encrypted. All letter should be transformed to upper case.

If the character is a space or newline, then the return value is a space or newline, respectively. Otherwise, if the letter is the first letter in a word then the numerical value of that letter (a=0, b=1, c=2, d=3, e=4, etc.) is added to the current julian day (from the date object) and the line number. The remainder of the new number/26 should be transformed back into a letter and that letter should be returned.

If the character is not the first character of a word, then the value of the previous character added to the value of the current character and remaindered by 26 should be converted to a letter and returned.

Decrypt takes an encoded message by this algorithm and turns it back into plaintext.

Note the border case "a,bc" would be the same as "abc" because the '','' is skipped as a symbol.

If there are no more valid letters, then a ''.'' is returned.

These two problems might be interesting for you. If you want more difficult ones, mention it again and I''ll post ''em.

-D
Make an MMORPG...
jk

Brian

EDIT: Actually I commend you for starting off the right way...unlike the standard "Hi I got a computer for my birthday, how would you go about making Quake 4? Links to tutorials only please"...more power to you buddy!

[edited by - bjmumblingmiles on December 22, 2002 1:12:12 AM]
Brian J
Advertisement
There were a set of exercises for game developers for C++ posted to this board a few weeks ago. I dont remember the download site now but if you give me an email address I can mail them to you.

The difficulty with finding exercises at such an early stage in your learning, is that you often find that you need to know xyz in order to do a particular exercise. Don''t worry too much about trying to understand everything 100% before moving on. Work through the book as you are, do the exercises and if you find yourself getting stuck later just go back and recap on that area. Also, I always find that reading about a subject from multiple sources helps me understand it better. If you dont get it after reading the way the first guy explains it, you may get it when you read the way the 2nd guy explains it.

Bruce Eckel is a great C++ and Java programmer who has published his ''Thinking In...'' books for free on the internet. Download the C++ one and refer to it on the subjects you get stuck on from the Sams book. Here is Bruce''s website :

http://www.mindview.net/

Caroline M.
Caroline M

This topic is closed to new replies.

Advertisement