Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3
This is the forum to discuss the Wrox book Beginning C# 3.0 : An Introduction to Object Oriented Programming by Jack Purdum; ISBN: 9780470261293
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 1st, 2010, 03:08 PM
Registered User
 
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 10 Question ref approach

The approach given on p250 to cycling through the cards in the deck took me some time to understand. Specifically the method used on the outer loop (missing out the increment element of the outer for loop).

Whilst I was able to understand why this was done I was surprised as I thought it was bad practise to tamper directly with loop variables in a for next loop. e.g. that incrementing should be left to the actual loop statement commands.

Is that just a misunderstanding on my part?

Many thanks in advance for any help you can give.

Guy

BTW this is the furthest I've got with any programming book I've ever tried. All kudos to Dr Purdum. Whilst the book has typos by the score and seems to have been badly edited its achieving with me what it promises.

It'll get 5 stars from me on Amazon.
  #2 (permalink)  
Old April 2nd, 2010, 11:28 AM
Friend of Wrox
Points: 1,166, Level: 13
Points: 1,166, Level: 13 Points: 1,166, Level: 13 Points: 1,166, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default Messin' with loops...

Hi Guy:

There are probably a dozen different algorithms that could be used to simulate shuffling a deck of cards. The actual code to shuffle the deck appears on page 252 in the ShuffleDeck() method. You'll note that I use a while loop in that code, not a for loop. This is because I want to sit in that loop and spin around until all 52 cards have been assigned a position in the deck. This count is maintain by index.

The actual code to display the deck does use a for loop with the 3rd expression missing in the loop statement, although the increment takes place inside the nested for loop. You could do this more simply using a while loop again. I did it the hard way just to demonstrate a nested for loop. As an exercise, try to rewrite the loops on page 250 using just a while loop. (Hint: You might find the expression cardindex % 13 useful!) Also, I hate using what I call "magic numbers" in code. So, while you're at it, define a constant for the 13 you see on that page. Perhaps CARDSPERLINE would be a good name.

I am sorry about the typos. If you have a list, submit them to Wrox ASAP as they are planning a second printing of my book. If done quickly enough, they may be able to incorporate the changes. I'm sure some of them have already been corrected, but perhaps not all.

The Amazon review would help. If you read the review of the guy who dinged my book, the actual review is pretty positive even though he gives me a 2-star rating. That one review really hurt my average. Even though he stated he'd like to redo the review and give the book a higher rating, he's never done so and, to the cursory reader, it doesn't look too good. Oh well, is it what it is...

Let me know how your rewrite of the loop goes. Often, redoing someone else's code is a good learning method.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
  #3 (permalink)  
Old April 2nd, 2010, 03:55 PM
Registered User
 
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Oh wow thanks for the quick response

Dr Purdum

Thank you for taking the time to respond to my question - the points you made all make sense to me and I'll take them as additional practise. Like I said the book seems to be doing for me what it claimed to - thats something of a first for me from the world of computer books (I think some things could improve it further but then they might bloat it out a bit and perhaps part of the success is the brevity).

The fact that you respond to questions like you do goes a long way. I do not understand why the person who gave the book a low rating has not changed it. What he says doesn't mesh with how he's rated the book.

I've just completed chapter 10 so still have 5 chapters to go. I will read them all before I post my review on Amazon. I'd rather be able to say something useful for readers in a review.

In the meantime have a happy easter.

Best wishes

Guy
  #4 (permalink)  
Old April 2nd, 2010, 11:42 PM
Friend of Wrox
Points: 1,166, Level: 13
Points: 1,166, Level: 13 Points: 1,166, Level: 13 Points: 1,166, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default Thanks

Thanks for the kind words, Guy. I know what it's like to have unanswered questions, so I do make an effort to check here every couple of days. Sometimes when I'm traveling I can't get to a computer (e.g., fly-in fishing trip last year), but I'll try to catch up when I get back.

Hope you enjoy the rest of the book. If something's fuzzy for you, chances are there's ten more just like you, so ask away...
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10 -Function question restated ChuckASP BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 April 2nd, 2010 03:38 PM
Chapter 10 Try it Out (Page 328) IDE Question: jsymons BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 September 9th, 2009 03:06 PM
Another chapter 10 question. czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 4 April 3rd, 2005 09:12 PM
Question on chapter 10 - overriding RobMeade BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 4 August 12th, 2004 11:56 AM



All times are GMT -4. The time now is 12:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.