WStoreyII, This is the type of problem that can be solved by walking through the code with a debugger, sometimes you need to walk though the code a couple of times... Look carefully at this routine: Public Class Deck Private Cards As System.Collections.SortedList = New System.Collections.SortedList(108) Public ReadOnly Property Collection() As System.Collections.SortedList Get Return Collection Collection = Cards End Get End Property End Class What does/is the first line of the Get doing? What does/is the second line of the Get doing? What should the (single) line of the Get be doing? Remember that Functions & Property Get methods have a hidden variable that acts as a return value. Hope this helps Jay [quoted text, click to view] "WStoreyII" <papastoreyii@sbcglobal.net> wrote in message news:XKJ7c.27262$_Q7.22802@newssvr29.news.prodigy.com...
when ever i run this code i get an error messager saying Object reference not set to an instance of an object. Deck.Collection.Add(Index, Me) but it is set to an instance in the collection property of the deck class what am i doing wrong? by the way this is my project for PHase 10 the card game just so that you knw what you are looking at WStoreyII Dim MyDeck As Deck = New Deck #Region " Cards " ' Phases Public Phase() As String = {"Phases", Phase1, Phase2, Phase3, Phase4, Phase5, Phase6, Phase7, Phase8, Phase9, Phase10} Public Const Phase1 As String = " 2 sets of 3 " Public Const Phase2 As String = " 1 set of 3 + 1 run of 4 " Public Const Phase3 As String = " 1 set of 4 + 1 run of 4 " Public Const Phase4 As String = " 1 run of 7 " Public Const Phase5 As String = " 1 run of 8 " Public Const Phase6 As String = " 1 run of 9 " Public Const Phase7 As String = " 2 sets of 4 " Public Const Phase8 As String = " 7 cards of one color " Public Const Phase9 As String = " 1 set of 5 + 1 set of 2 " Public Const Phase10 As String = " 1 set of 5 + 1 set of 3 " 'Red Cards 1 - 12 Public RCF1 As Card = New Card(MyDeck, "Red", 5, 1, "1") Public RCF2 As Card = New Card(MyDeck, "Red", 5, 2, "2") Public RCF3 As Card = New Card(MyDeck, "Red", 5, 3, "3") Public RCF4 As Card = New Card(MyDeck, "Red", 5, 4, "4") Public RCF5 As Card = New Card(MyDeck, "Red", 5, 5, "5") Public RCF6 As Card = New Card(MyDeck, "Red", 5, 6, "6") Public RCF7 As Card = New Card(MyDeck, "Red", 5, 7, "7") Public RCF8 As Card = New Card(MyDeck, "Red", 5, 8, "8") Public RCF9 As Card = New Card(MyDeck, "Red", 5, 9, "9") Public RCF10 As Card = New Card(MyDeck, "Red", 10, 10, "10") Public RCF11 As Card = New Card(MyDeck, "Red", 10, 11, "11") Public RCF12 As Card = New Card(MyDeck, "Red", 10, 12, "12") Public RCS1 As Card = New Card(MyDeck, "Red", 5, 13, "1") Public RCS2 As Card = New Card(MyDeck, "Red", 5, 14, "2") Public RCS3 As Card = New Card(MyDeck, "Red", 5, 15, "3") Public RCS4 As Card = New Card(MyDeck, "Red", 5, 16, "4") Public RCS5 As Card = New Card(MyDeck, "Red", 5, 17, "5") Public RCS6 As Card = New Card(MyDeck, "Red", 5, 18, "6") Public RCS7 As Card = New Card(MyDeck, "Red", 5, 19, "7") Public RCS8 As Card = New Card(MyDeck, "Red", 5, 20, "8") Public RCS9 As Card = New Card(MyDeck, "Red", 5, 21, "9") Public RCS10 As Card = New Card(MyDeck, "Red", 10, 22, "10") Public RCS11 As Card = New Card(MyDeck, "Red", 10, 23, "11") Public RCS12 As Card = New Card(MyDeck, "Red", 10, 24, "12") 'Blue Cards 1 - 12 Public BCF1 As Card = New Card(MyDeck, "Blue", 5, 25, "1") Public BCF2 As Card = New Card(MyDeck, "Blue", 5, 26, "2") Public BCF3 As Card = New Card(MyDeck, "Blue", 5, 27, "3") Public BCF4 As Card = New Card(MyDeck, "Blue", 5, 28, "4") Public BCF5 As Card = New Card(MyDeck, "Blue", 5, 29, "5") Public BCF6 As Card = New Card(MyDeck, "Blue", 5, 30, "6") Public BCF7 As Card = New Card(MyDeck, "Blue", 5, 31, "7") Public BCF8 As Card = New Card(MyDeck, "Blue", 5, 32, "8") Public BCF9 As Card = New Card(MyDeck, "Blue", 5, 33, "9") Public BCF10 As Card = New Card(MyDeck, "Blue", 10, 34, "10") Public BCF11 As Card = New Card(MyDeck, "Blue", 10, 35, "11") Public BCF12 As Card = New Card(MyDeck, "Blue", 10, 36, "12") Public BCS1 As Card = New Card(MyDeck, "Blue", 5, 37, "1") Public BCS2 As Card = New Card(MyDeck, "Blue", 5, 38, "2") Public BCS3 As Card = New Card(MyDeck, "Blue", 5, 39, "3") Public BCS4 As Card = New Card(MyDeck, "Blue", 5, 40, "4") Public BCS5 As Card = New Card(MyDeck, "Blue", 5, 41, "5") Public BCS6 As Card = New Card(MyDeck, "Blue", 5, 42, "6") Public BCS7 As Card = New Card(MyDeck, "Blue", 5, 43, "7") Public BCS8 As Card = New Card(MyDeck, "Blue", 5, 44, "8") Public BCS9 As Card = New Card(MyDeck, "Blue", 5, 45, "9") Public BCS10 As Card = New Card(MyDeck, "Blue", 10, 46, "10") Public BCS11 As Card = New Card(MyDeck, "Blue", 10, 47, "11") Public BCS12 As Card = New Card(MyDeck, "Blue", 10, 48, "12") 'Green Cards 1 - 12 Public GCF1 As Card = New Card(MyDeck, "Green", 5, 49, "1") Public GCF2 As Card = New Card(MyDeck, "Green", 5, 50, "2") Public GCF3 As Card = New Card(MyDeck, "Green", 5, 51, "3") Public GCF4 As Card = New Card(MyDeck, "Green", 5, 52, "4") Public GCF5 As Card = New Card(MyDeck, "Green", 5, 53, "5") Public GCF6 As Card = New Card(MyDeck, "Green", 5, 54, "6") Public GCF7 As Card = New Card(MyDeck, "Green", 5, 55, "7") Public GCF8 As Card = New Card(MyDeck, "Green", 5, 56, "8") Public GCF9 As Card = New Card(MyDeck, "Green", 5, 57, "9") Public GCF10 As Card = New Card(MyDeck, "Green", 10, 58, "10") Public GCF11 As Card = New Card(MyDeck, "Green", 10, 59, "11") Public GCF12 As Card = New Card(MyDeck, "Green", 10, 60, "12") Public GCS1 As Card = New Card(MyDeck, "Green", 5, 61, "1") Public GCS2 As Card = New Card(MyDeck, "Green", 5, 62, "2") Public GCS3 As Card = New Card(MyDeck, "Green", 5, 63, "3") Public GCS4 As Card = New Card(MyDeck, "Green", 5, 64, "4") Public GCS5 As Card = New Card(MyDeck, "Green", 5, 65, "5") Public GCS6 As Card = New Card(MyDeck, "Green", 5, 66, "6") Public GCS7 As Card = New Card(MyDeck, "Green", 5, 67, "7") Public GCS8 As Card = New Card(MyDeck, "Green", 5, 68, "8") Public GCS9 As Card = New Card(MyDeck, "Green", 5, 69, "9") Public GCS10 As Card = New Card(MyDeck, "Green", 10, 70, "10") Public GCS11 As Card = New Card(MyDeck, "Green", 10, 71, "11") Public GCS12 As Card = New Card(MyDeck, "Green", 10, 72, "12") 'Yellow Cards 1 - 12 Public YCF1 As Card = New Card(MyDeck, "Yellow", 5, 73, "1") Public YCF2 As Card = New Card(MyDeck, "Yellow", 5, 74, "2") Public YCF3 As Card = New Card(MyDeck, "Yellow", 5, 75, "3") Public YCF4 As Card = New Card(MyDeck, "Yellow", 5, 76, "4") Public YCF5 As Card = New Card(MyDeck, "Yellow", 5, 77, "5") Public YCF6 As Card = New Card(MyDeck, "Yellow", 5, 78, "6") Public YCF7 As Card = New Card(MyDeck, "Yellow", 5, 79, "7") Public YCF8 As Card = New Card(MyDeck, "Yellow", 5, 80, "8")
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote... [quoted text, click to view] > WStoreyII, > This is the type of problem that can be solved by walking through the code > with a debugger, sometimes you need to walk though the code a couple of > times...
It can? :-) Mr. Storey... perhaps you think I'm a dope or something and in that case I'll just steer around your messages but do understand that I'm attempting to be helpful. If you plan things out first the process will go faster, the code will look cleaner, the program will run better and you will be a better programmer for having understood the process. Let me just leave it at that for now. I wrote the shuffle routine in VB.Net if you would like that posted... Tom
when ever i run this code i get an error messager saying=20 Object reference not set to an instance of an object. Deck.Collection.Add(Index, Me) but it is set to an instance in the collection property of the deck = class=20 what am i doing wrong? by the way this is my project for PHase 10 the card game just so that = you knw what you are looking at=20 WStoreyII Dim MyDeck As Deck =3D New Deck #Region " Cards " ' Phases=20 Public Phase() As String =3D {"Phases", Phase1, Phase2, Phase3, Phase4, = Phase5, Phase6, Phase7, Phase8, Phase9, Phase10} Public Const Phase1 As String =3D " 2 sets of 3 " Public Const Phase2 As String =3D " 1 set of 3 + 1 run of 4 " Public Const Phase3 As String =3D " 1 set of 4 + 1 run of 4 " Public Const Phase4 As String =3D " 1 run of 7 " Public Const Phase5 As String =3D " 1 run of 8 " Public Const Phase6 As String =3D " 1 run of 9 " Public Const Phase7 As String =3D " 2 sets of 4 " Public Const Phase8 As String =3D " 7 cards of one color " Public Const Phase9 As String =3D " 1 set of 5 + 1 set of 2 " Public Const Phase10 As String =3D " 1 set of 5 + 1 set of 3 " 'Red Cards 1 - 12=20 Public RCF1 As Card =3D New Card(MyDeck, "Red", 5, 1, "1") Public RCF2 As Card =3D New Card(MyDeck, "Red", 5, 2, "2") Public RCF3 As Card =3D New Card(MyDeck, "Red", 5, 3, "3") Public RCF4 As Card =3D New Card(MyDeck, "Red", 5, 4, "4") Public RCF5 As Card =3D New Card(MyDeck, "Red", 5, 5, "5") Public RCF6 As Card =3D New Card(MyDeck, "Red", 5, 6, "6") Public RCF7 As Card =3D New Card(MyDeck, "Red", 5, 7, "7") Public RCF8 As Card =3D New Card(MyDeck, "Red", 5, 8, "8") Public RCF9 As Card =3D New Card(MyDeck, "Red", 5, 9, "9") Public RCF10 As Card =3D New Card(MyDeck, "Red", 10, 10, "10") Public RCF11 As Card =3D New Card(MyDeck, "Red", 10, 11, "11") Public RCF12 As Card =3D New Card(MyDeck, "Red", 10, 12, "12") Public RCS1 As Card =3D New Card(MyDeck, "Red", 5, 13, "1") Public RCS2 As Card =3D New Card(MyDeck, "Red", 5, 14, "2") Public RCS3 As Card =3D New Card(MyDeck, "Red", 5, 15, "3") Public RCS4 As Card =3D New Card(MyDeck, "Red", 5, 16, "4") Public RCS5 As Card =3D New Card(MyDeck, "Red", 5, 17, "5") Public RCS6 As Card =3D New Card(MyDeck, "Red", 5, 18, "6") Public RCS7 As Card =3D New Card(MyDeck, "Red", 5, 19, "7") Public RCS8 As Card =3D New Card(MyDeck, "Red", 5, 20, "8") Public RCS9 As Card =3D New Card(MyDeck, "Red", 5, 21, "9") Public RCS10 As Card =3D New Card(MyDeck, "Red", 10, 22, "10") Public RCS11 As Card =3D New Card(MyDeck, "Red", 10, 23, "11") Public RCS12 As Card =3D New Card(MyDeck, "Red", 10, 24, "12") 'Blue Cards 1 - 12=20 Public BCF1 As Card =3D New Card(MyDeck, "Blue", 5, 25, "1") Public BCF2 As Card =3D New Card(MyDeck, "Blue", 5, 26, "2") Public BCF3 As Card =3D New Card(MyDeck, "Blue", 5, 27, "3") Public BCF4 As Card =3D New Card(MyDeck, "Blue", 5, 28, "4") Public BCF5 As Card =3D New Card(MyDeck, "Blue", 5, 29, "5") Public BCF6 As Card =3D New Card(MyDeck, "Blue", 5, 30, "6") Public BCF7 As Card =3D New Card(MyDeck, "Blue", 5, 31, "7") Public BCF8 As Card =3D New Card(MyDeck, "Blue", 5, 32, "8") Public BCF9 As Card =3D New Card(MyDeck, "Blue", 5, 33, "9") Public BCF10 As Card =3D New Card(MyDeck, "Blue", 10, 34, "10") Public BCF11 As Card =3D New Card(MyDeck, "Blue", 10, 35, "11") Public BCF12 As Card =3D New Card(MyDeck, "Blue", 10, 36, "12") Public BCS1 As Card =3D New Card(MyDeck, "Blue", 5, 37, "1") Public BCS2 As Card =3D New Card(MyDeck, "Blue", 5, 38, "2") Public BCS3 As Card =3D New Card(MyDeck, "Blue", 5, 39, "3") Public BCS4 As Card =3D New Card(MyDeck, "Blue", 5, 40, "4") Public BCS5 As Card =3D New Card(MyDeck, "Blue", 5, 41, "5") Public BCS6 As Card =3D New Card(MyDeck, "Blue", 5, 42, "6") Public BCS7 As Card =3D New Card(MyDeck, "Blue", 5, 43, "7") Public BCS8 As Card =3D New Card(MyDeck, "Blue", 5, 44, "8") Public BCS9 As Card =3D New Card(MyDeck, "Blue", 5, 45, "9") Public BCS10 As Card =3D New Card(MyDeck, "Blue", 10, 46, "10") Public BCS11 As Card =3D New Card(MyDeck, "Blue", 10, 47, "11") Public BCS12 As Card =3D New Card(MyDeck, "Blue", 10, 48, "12") 'Green Cards 1 - 12=20 Public GCF1 As Card =3D New Card(MyDeck, "Green", 5, 49, "1") Public GCF2 As Card =3D New Card(MyDeck, "Green", 5, 50, "2") Public GCF3 As Card =3D New Card(MyDeck, "Green", 5, 51, "3") Public GCF4 As Card =3D New Card(MyDeck, "Green", 5, 52, "4") Public GCF5 As Card =3D New Card(MyDeck, "Green", 5, 53, "5") Public GCF6 As Card =3D New Card(MyDeck, "Green", 5, 54, "6") Public GCF7 As Card =3D New Card(MyDeck, "Green", 5, 55, "7") Public GCF8 As Card =3D New Card(MyDeck, "Green", 5, 56, "8") Public GCF9 As Card =3D New Card(MyDeck, "Green", 5, 57, "9") Public GCF10 As Card =3D New Card(MyDeck, "Green", 10, 58, "10") Public GCF11 As Card =3D New Card(MyDeck, "Green", 10, 59, "11") Public GCF12 As Card =3D New Card(MyDeck, "Green", 10, 60, "12") Public GCS1 As Card =3D New Card(MyDeck, "Green", 5, 61, "1") Public GCS2 As Card =3D New Card(MyDeck, "Green", 5, 62, "2") Public GCS3 As Card =3D New Card(MyDeck, "Green", 5, 63, "3") Public GCS4 As Card =3D New Card(MyDeck, "Green", 5, 64, "4") Public GCS5 As Card =3D New Card(MyDeck, "Green", 5, 65, "5") Public GCS6 As Card =3D New Card(MyDeck, "Green", 5, 66, "6") Public GCS7 As Card =3D New Card(MyDeck, "Green", 5, 67, "7") Public GCS8 As Card =3D New Card(MyDeck, "Green", 5, 68, "8") Public GCS9 As Card =3D New Card(MyDeck, "Green", 5, 69, "9") Public GCS10 As Card =3D New Card(MyDeck, "Green", 10, 70, "10") Public GCS11 As Card =3D New Card(MyDeck, "Green", 10, 71, "11") Public GCS12 As Card =3D New Card(MyDeck, "Green", 10, 72, "12") 'Yellow Cards 1 - 12=20 Public YCF1 As Card =3D New Card(MyDeck, "Yellow", 5, 73, "1") Public YCF2 As Card =3D New Card(MyDeck, "Yellow", 5, 74, "2") Public YCF3 As Card =3D New Card(MyDeck, "Yellow", 5, 75, "3") Public YCF4 As Card =3D New Card(MyDeck, "Yellow", 5, 76, "4") Public YCF5 As Card =3D New Card(MyDeck, "Yellow", 5, 77, "5") Public YCF6 As Card =3D New Card(MyDeck, "Yellow", 5, 78, "6") Public YCF7 As Card =3D New Card(MyDeck, "Yellow", 5, 79, "7") Public YCF8 As Card =3D New Card(MyDeck, "Yellow", 5, 80, "8") Public YCF9 As Card =3D New Card(MyDeck, "Yellow", 5, 81, "9") Public YCF10 As Card =3D New Card(MyDeck, "Yellow", 10, 82, "10") Public YCF11 As Card =3D New Card(MyDeck, "Yellow", 10, 83, "11") Public YCF12 As Card =3D New Card(MyDeck, "Yellow", 10, 84, "12") Public YCS1 As Card =3D New Card(MyDeck, "Yellow", 5, 85, "1") Public YCS2 As Card =3D New Card(MyDeck, "Yellow", 5, 86, "2") Public YCS3 As Card =3D New Card(MyDeck, "Yellow", 5, 87, "3") Public YCS4 As Card =3D New Card(MyDeck, "Yellow", 5, 88, "4") Public YCS5 As Card =3D New Card(MyDeck, "Yellow", 5, 89, "5") Public YCS6 As Card =3D New Card(MyDeck, "Yellow", 5, 90, "6") Public YCS7 As Card =3D New Card(MyDeck, "Yellow", 5, 91, "7")
Tom, [quoted text, click to view] > It can? :-)
Yes! Especially when I gave him the routine that has the problem, and I hopefully gave him four very good clues on what the problem is. If you single step the routine I identified watching all the variables that I had questions on, when it occurs to you what the problem is, it should hit you like a ton of bricks. Also I hope you will have a new found appriciation for distaining the hidden variable on Property Get & Functions. Yes it bit me the other day on something on a contract position. Granted if you are seeing other problems (other then the NullReference) then you are welcome to identify those, I was only referring to the NullReference Mr Story asked about. Hope this helps Jay [quoted text, click to view] "Tom Leylan" <gee@iamtiredofspam.com> wrote in message news:utKXVnGEEHA.1452@TK2MSFTNGP09.phx.gbl... > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote... > > WStoreyII, > > This is the type of problem that can be solved by walking through the code > > with a debugger, sometimes you need to walk though the code a couple of > > times... > > It can? :-) > > Mr. Storey... perhaps you think I'm a dope or something and in that case > I'll just steer around your messages but do understand that I'm attempting > to be helpful. If you plan things out first the process will go faster, the > code will look cleaner, the program will run better and you will be a better > programmer for having understood the process. > > Let me just leave it at that for now. I wrote the shuffle routine in VB.Net > if you would like that posted... > > Tom > > >
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote... [quoted text, click to view] > Tom, > > It can? :-) > Granted if you are seeing other problems (other then the NullReference) then > you are welcome to identify those, I was only referring to the NullReference > Mr Story asked about.
Hi Jay... it was an attempt at a joke since you mentioned "this type of problem" and I saw perhaps a dozen problems. I get the sense that the OP wants to solve the "fatal bug" rather than discuss the solution however. That's not unusual per se but it often means there will be a series of "now it's doing this" and "how do I get it to stop doing that" questions following on shortly. Many of the problems people encounter wouldn't exist if they considered a different tack through the rocky shoals.
[quoted text, click to view] "WStoreyII" <papastoreyii@sbcglobal.net> wrote in message news:5VY7c.41632$wc3.7026@newssvr25.news.prodigy.com... > hey im open to any suggestions that you have > i am still new and with my limited vb.net or programming knowledge this > seemed to be the best way about going to building this game
I try not to sound rude but it is often almost impossible not to seem rude when one "challenges" people's code, if you know what I mean. One way of knowing if you are on the right track (or let's say a "good" track) is if you can describe your solution "before" you start writing it. You are writing a card game so a "deck" class seems likely and a "card" class seems obvious. And we know there will be rules and something has to paint the cards, etc. So check the solution you posted. You have a card class that inherits from SystemWindows.Forms.Label. Generally speaking what would a playing card have in common with a label? What is it in the label that you find so card-like that you consider this a step towards developing your card class? Does the question cause you to pause and ask yourself, uhhh yes what was I thinking? Or is your reaction "you don't understand I need to display the cards, blah, blah"? It may not seem like it but I do understand that you need to display the cards. I also understand that you might like them to be displayed in a picturebox one day. Now consider how you place cards into the deck. You pass a deck object to a card constructor. The card object references the internal collection of the deck. You pass (among other things) an incrementing index number. Pass the wrong number and things get messed up. You're passing a text string representing a color which the constructor immediately turns back into an actual color. If you pass "Green" in English you have to write code to convert it, you run the risk of typing it wrong and you have to add more case statements to support "Cyan" or "Magenta" if you pass along a color none of these restrictions exist. Consider that a deck of cards is (for most purposes) a "datasource" no different than any other data source one might use in an application. If you look at the way datasources are handled in .Net you will see that "binding" them to controls is a useful practice. This suggests that you should not derive a Card class from a label but that you should create a deck class that maintains and services a collection of card objects. The deck should probably have a AddCard method. It can then have a DeleteCard, a Shuffle, a Draw and whatever deck-related things you need. And if you select databinding as a methodology you can bind your deck and cards to various controls (or none at all.) My point is just that the more "unlike" a deck of cards your deck/card classes are the more likely you will run into trouble. If you did nothing else couldn't the deck constructor add all your cards for you? Why would the form need to construct the only deck of cards it will ever need every time? I realize you don't need it but how nice if you could simply write something along the lines of: Dim Deck1 as Deck = New Deck Dim Deck2 as Deck = New Deck and you would have two decks... the way you have it written you have to have the form add 108 cards into the each of the decks. In any case... I'm not suggesting I know all the answers but I am suggesting you are (seemingly) making the project more difficult than it needs to be. I hope this helps. Tom
yes jay and i thank you it did work and i did trouble shoot the code but i still miss things WStoreyII Thanks for all the help [quoted text, click to view] "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message news:ezfHJ2NEEHA.3344@tk2msftngp13.phx.gbl... > Tom, > > It can? :-) > > Yes! > > Especially when I gave him the routine that has the problem, and I hopefully > gave him four very good clues on what the problem is. > > If you single step the routine I identified watching all the variables that > I had questions on, when it occurs to you what the problem is, it should hit > you like a ton of bricks. > > Also I hope you will have a new found appriciation for distaining the hidden > variable on Property Get & Functions. Yes it bit me the other day on > something on a contract position. > > Granted if you are seeing other problems (other then the NullReference) then > you are welcome to identify those, I was only referring to the NullReference > Mr Story asked about. > > Hope this helps > Jay > > > "Tom Leylan" <gee@iamtiredofspam.com> wrote in message > news:utKXVnGEEHA.1452@TK2MSFTNGP09.phx.gbl... > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote... > > > WStoreyII, > > > This is the type of problem that can be solved by walking through the > code > > > with a debugger, sometimes you need to walk though the code a couple of > > > times... > > > > It can? :-) > > > > Mr. Storey... perhaps you think I'm a dope or something and in that case > > I'll just steer around your messages but do understand that I'm attempting > > to be helpful. If you plan things out first the process will go faster, > the > > code will look cleaner, the program will run better and you will be a > better > > programmer for having understood the process. > > > > Let me just leave it at that for now. I wrote the shuffle routine in > VB.Net > > if you would like that posted... > > > > Tom > > > > > > > >
hey im open to any suggestions that you have i am still new and with my limited vb.net or programming knowledge this seemed to be the best way about going to building this game WStoreyII [quoted text, click to view] "Tom Leylan" <gee@iamtiredofspam.com> wrote in message news:enxJsXOEEHA.3412@TK2MSFTNGP10.phx.gbl... > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote... > > Tom, > > > It can? :-) > > > Granted if you are seeing other problems (other then the NullReference) > then > > you are welcome to identify those, I was only referring to the > NullReference > > Mr Story asked about. > > Hi Jay... it was an attempt at a joke since you mentioned "this type of > problem" and I saw perhaps a dozen problems. I get the sense that the OP > wants to solve the "fatal bug" rather than discuss the solution however. > That's not unusual per se but it often means there will be a series of "now > it's doing this" and "how do I get it to stop doing that" questions > following on shortly. > > Many of the problems people encounter wouldn't exist if they considered a > different tack through the rocky shoals. > >
[quoted text, click to view] On Tue, 23 Mar 2004 21:01:10 GMT, WStoreyII wrote: > making flow charts and stuff. And i am going to scan the cards tonigth and > add them to an image list. I agree with you idea about a deck class and
This is just an FYI, but in the \windows\system32\ folder (on WinXP) there is a cards.dll that has all the card images. I believe that you can use that with your game. Also, at www.gotdotnet.com, there is an example of how to get the images from the .dll. -- Chris To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
"WStoreyII" <papastoreyii@sbcglobal.net> wrote... [quoted text, click to view] > Thank you for all that advice, yes my original approach to the game
sucked. Let's call it "sub-optimal" :-) [quoted text, click to view] > And i am going to scan the cards tonigth and add them to an image list.
Want another time-saving hint? Don't scan the cards tonight... your project isn't "nearly complete except for the card images" and we know that you can operate the scanner. These are delay tactics that people (including programmers) use all the time. You'll get so caught up in fixing some graphics that the program won't get written. And you can always fancy it up later. [quoted text, click to view] > I see you point though that its easier (on memory to i presume) to create > instances of the cards and decks instead of creating it all.
I'm not too worried about memory, we can always buy more and it is virtualized in Windows in any case. If you needed to maintain reference pointers to every card in the deck then by all means set them up. I'll guess that you don't need it. Using memory is one thing, wasting memory (and your time wasting that memory) is another. [quoted text, click to view] > as well as your patience with a newbie who wishes to run before he crawls
I'm glad you feel that way, messages aren't the perfect communication device but it will have to do. As for crawling, consider completing each "part" of the game instead of the entire card game. Write a Deck class and a Card class and simply play with them for awhile. No positions on the screen, no graphics, nothing unrelated to the Deck and the Cards. Have it output the values using Console.WriteLine. Make sure that you can add a card, delete a card, traverse the deck reporting the value of each card, shuffle the deck, report how many cards remain in the deck, etc. Do you need a discard pile? Do you need a player's Hand class to hold a set of cards? At some point later on you will have most of it working and you can add the graphics. When you do you can decide if the application maintains this (is it part of the GUI?) or are the images somehow associated with either the Deck Class or the Cards themselves. Surprisingly, if you take your time you will actually finish it faster. Tom
Tom , Thank you for all that advice, yes my original approach to the game sucked. I do not have a lot of scope right now as to what vb.net or any programing language is capable of. I have started to reorganize the project i am making flow charts and stuff. And i am going to scan the cards tonigth and add them to an image list. I agree with you idea about a deck class and card class, this is what i came up with last night when designing it and some posted to make my own card collection class that derives from collection base and i am going to give that a try to. I see you point though that its easier (on memory to i presume) to create instances of the cards and decks instead of creating it all. dont feel afraid of sounding rude that is the point. I asked you to tell me what was wrong, you tell me what you think i make any neccesary changes i feel like. if i dont take your advice its my fault there is no rudeness invovled in that and i thank you for your honesty and your help as well as your patience with a newbie who wishes to run before he crawls WStoreyII [quoted text, click to view] "Tom Leylan" <gee@iamtiredofspam.com> wrote in message news:uT%23TQjPEEHA.1128@TK2MSFTNGP11.phx.gbl... > "WStoreyII" <papastoreyii@sbcglobal.net> wrote in message > news:5VY7c.41632$wc3.7026@newssvr25.news.prodigy.com... > > hey im open to any suggestions that you have > > i am still new and with my limited vb.net or programming knowledge this > > seemed to be the best way about going to building this game > > I try not to sound rude but it is often almost impossible not to seem rude > when one "challenges" people's code, if you know what I mean. > > One way of knowing if you are on the right track (or let's say a "good" > track) is if you can describe your solution "before" you start writing it. > You are writing a card game so a "deck" class seems likely and a "card" > class seems obvious. And we know there will be rules and something has to > paint the cards, etc. > > So check the solution you posted. You have a card class that inherits from > SystemWindows.Forms.Label. Generally speaking what would a playing card > have in common with a label? What is it in the label that you find so > card-like that you consider this a step towards developing your card class? > Does the question cause you to pause and ask yourself, uhhh yes what was I > thinking? Or is your reaction "you don't understand I need to display the > cards, blah, blah"? It may not seem like it but I do understand that you > need to display the cards. I also understand that you might like them to be > displayed in a picturebox one day. > > Now consider how you place cards into the deck. You pass a deck object to a > card constructor. The card object references the internal collection of the > deck. You pass (among other things) an incrementing index number. Pass the > wrong number and things get messed up. You're passing a text string > representing a color which the constructor immediately turns back into an > actual color. If you pass "Green" in English you have to write code to > convert it, you run the risk of typing it wrong and you have to add more > case statements to support "Cyan" or "Magenta" if you pass along a color > none of these restrictions exist. > > Consider that a deck of cards is (for most purposes) a "datasource" no > different than any other data source one might use in an application. If > you look at the way datasources are handled in .Net you will see that > "binding" them to controls is a useful practice. This suggests that you > should not derive a Card class from a label but that you should create a > deck class that maintains and services a collection of card objects. The > deck should probably have a AddCard method. It can then have a DeleteCard, > a Shuffle, a Draw and whatever deck-related things you need. And if you > select databinding as a methodology you can bind your deck and cards to > various controls (or none at all.) > > My point is just that the more "unlike" a deck of cards your deck/card > classes are the more likely you will run into trouble. If you did nothing > else couldn't the deck constructor add all your cards for you? Why would > the form need to construct the only deck of cards it will ever need every > time? I realize you don't need it but how nice if you could simply write > something along the lines of: > > Dim Deck1 as Deck = New Deck > Dim Deck2 as Deck = New Deck > > and you would have two decks... the way you have it written you have to have > the form add 108 cards into the each of the decks. > > In any case... I'm not suggesting I know all the answers but I am suggesting > you are (seemingly) making the project more difficult than it needs to be. > > I hope this helps. > Tom > > > > > > > > >
Don't see what you're looking for? Try a search.
|