Click here to Skip to main content
15,896,269 members
Articles / Programming Languages / Visual Basic

Build Mobile PC Awareness lnto Mobile PC agnostic Windows Forms apps using Inheritance.

Rate me:
Please Sign up or sign in to vote.
4.19/5 (8 votes)
18 May 2007CPOL6 min read 35K   714   17  
Easily incorporate ink, power, network and size awareness into a Windows Form Application. The "Black Jack Card Game Starter Kit" is used as an example of a Mobile PC unaware app that is converted into a Mobile PC app by inheriting from the MobilePCAwareForm included with the download.
Namespace CardGameFramework

    ''' <summary>
    ''' Card suit values
    ''' </summary>
    Public Enum Suit
        Diamonds
        Spades
        Clubs
        Hearts
    End Enum

    ''' <summary>
    ''' Card face values
    ''' </summary>
    Public Enum FaceValue
        Two = 2
        Three = 3
        Four = 4
        Five = 5
        Six = 6
        Seven = 7
        Eight = 8
        Nine = 9
        Ten = 10
        Jack = 11
        Queen = 12
        King = 13
        Ace = 14
    End Enum

    Public Class Card
        ' Objects for card information
        Private _suitProp As Suit
        Private _faceValProp As FaceValue
        Private _isCardUpProp As Boolean

        Public Property Suit() As Suit
            Get
                Return _suitProp
            End Get
            Set(ByVal value As Suit)
                _suitProp = value
            End Set
        End Property

        Public Property FaceVal() As FaceValue
            Get
                Return _faceValProp
            End Get
            Set(ByVal value As FaceValue)
                _faceValProp = value
            End Set
        End Property

        Public Property IsCardUp() As Boolean
            Get
                Return _isCardUpProp
            End Get
            Set(ByVal value As Boolean)
                _isCardUpProp = value
            End Set
        End Property

        ''' <summary>
        ''' Constructor for a new card. 
        ''' </summary>
        ''' <param name="suitProp"></param>
        ''' <param name="faceValProp"></param>
        ''' <param name="isCardUpProp"></param>
        ''' <remarks>Assign the card a suit, face value, and if the card is facing up or down</remarks>
        Public Sub New(ByVal suitProp As Suit, ByVal faceValProp As FaceValue, ByVal isCardUpProp As Boolean)
            Me._suitProp = suitProp
            Me._faceValProp = faceValProp
            Me._isCardUpProp = isCardUpProp
        End Sub

        ''' <summary>
        ''' Return the card as a string (i.e. "The Ace of Spades")
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Overloads Overrides Function ToString() As String
            Return "The" & _faceValProp.ToString & "of" & _suitProp.ToString
        End Function
    End Class
End Namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions