Saturday, 10 August 2013

How to call a method without first calling it's constructor in C#

How to call a method without first calling it's constructor in C#

I hope I can make this work without uploading my code. I have a Draw Poker
console application in VS 2012 with about 5 classes that is object
oriented. Yes, it is homework but I am an experienced developer learning
C#.
My objective is to replenish the deck after every hand so that the player
can draw from 52 cards and conceivably lose 100 points at 1 point per
draw. This is not possible if the deck is depleted after a few draws,
which is happening.
Problem: I was told to call a CreateDeck method but I don't see how to do
so without calling the constructor. Yet if I do, a new Deck object is
instantiated but not referenced; the original deck is referenced and
depleted rapidly through each draw.
Associated problem is that multiple DealHands are executed per draw
thereby multiply the pace at which the deck is depleted.
Since this system is hundreds of lines of code scattered across five
classes, I don't see how to include my code. While I could, obviously
include the method calls, I was told that the constructor will not work on
itself. Not sure what the instructor meant.
I can email the zipped system to an interested party.
Thank you.

No comments:

Post a Comment