Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > BOOK: Beginning Visual C# 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Visual C# 2005
This is the forum to discuss the Wrox book Beginning Visual C# 2005 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, Eric White; ISBN: 9780764578472
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2005 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 10th, 2008, 01:52 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 10 page 268 Client application card deck

 1using System;
 2using System.Collections.Generic;
 3using System.Text;
 4using Ch10CardLib;
 5
 6namespace Ch10CardClient
 7{
 8 class Program
 9 {
10 static void Main(string[] args)
11 {
12 Deck myDeck = new Deck();
13 myDeck.Shuffle();
14 for (int i = 0; i < 52; i++)
15 {
16 Card tempCard = myDeck.GetCard(i);
17 Console.Write(tempCard.ToString());
18 if (i != 51)
19 Console.Write(", ");
20 else
21 Console.WriteLine();
22 }
23 Console.ReadKey();
24 }
25 }
26}

        public Card GetCard(int cardNum)
        {
            if (cardNum >= 0 && cardNum <= 51)
                return cards[cardNum];
            else
                throw (new System.ArgumentOutOfRangeException("cardNum", cardNum, "Value must be between 0 and 51."));
        }

on line 16 Card tempCard = myDeck.GetCard(i);

GetCard return cards[cardNum]

how do you assign value of cards[cardNum] to tempCard? isn't tempCard is the variable type of Card?

Reply With Quote
  #2 (permalink)  
Old December 5th, 2008, 07:54 AM
Authorized User
 
Join Date: Feb 2007
Location: Southampton, Hampshire, United Kingdom.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If I understand your post correctly, the method GetCard does not return a Cards object. It returns a Card object from within the internal Cards collection of Deck. cards[cardNum] returns a Card object at the position within cards specified by cardNum.

Reply With Quote
  #3 (permalink)  
Old April 13th, 2009, 02:03 PM
Registered User
 
Join Date: Feb 2008
Location: Florence, Arizona, USA.
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to Johndecoville
Default

cardNum does not seem to be defined anywhere.
Reply With Quote
Reply


Thread Tools
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, Try it out Page 365, C#, line 7 tbroom BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 June 12th, 2007 10:23 PM
Errata - Chapter 10, Page 378, C# RobC BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 August 31st, 2006 09:56 AM
Errata - Chapter 10, Page 376, C# RobC BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 August 31st, 2006 09:07 AM
Ex 10, Chapter 5, page 253 Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 1 June 16th, 2006 01:14 AM
Chapter 10, Try It Out error, page 380 VictorVictor BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 February 13th, 2006 11:41 AM



All times are GMT -4. The time now is 05:34 PM.


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