Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > BOOK: Beginning Visual C# 2005
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 10th, 2008, 01:52 AM
Registered User
 
Join Date: Jun 2008
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?

 
Old December 5th, 2008, 08:54 AM
Authorized User
 
Join Date: Feb 2007
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.

 
Old April 13th, 2009, 02:03 PM
Registered User
 
Join Date: Feb 2008
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.





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 12:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.