p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Visual C# 2005 (http://p2p.wrox.com/forumdisplay.php?f=222)
-   -   Chapter 10 CardLib (http://p2p.wrox.com/showthread.php?t=40094)

jacobl March 20th, 2006 03:05 PM

Chapter 10 CardLib
 
I recently purchased this book and I must say its outstanding. My question, on P261 of the Chapter 10 CardLib Class library, I am not able to do the following.

1. My Toolbox does not contain any Enum.
2. When adding the Suit Enumerator on the blank Class diagram, I get a message box with "Failed to create namespace Chap10CardLib"

Am I doing something wrong or am I missing something here.

Help will be really appreciated.


webworldman August 16th, 2006 10:03 AM

Enum is easy to code in. I use the Express Edition. So I don't expect to use the Class diagram. Just type in the following code.

using System;
using System.Collections.Generic;
using System.Text;

namespace Ch10CardLib
{
    public enum Suit
    {
        Club,
        Diamond,
        Heart,
        Spade
    }
    public enum Rank
    {
        Ace = 1,
        Deuce,
        Three,
        Four,
        Five,
        Six,
        Seven,
        Eight,
        Nine,
        Ten,
        Jack,
        Queen,
        King
    }
    public class Card
    {
        public readonly Suit suit;
        public readonly Rank rank;

        private Card()
        {
        }
        public Card(Suit newSuit, Rank newRank)
        {
            suit = newSuit;
            rank = newRank;
        }
        public override string ToString()
        {
            return "The " + rank + " of " + suit + "s";
        }
    }
}




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

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