Jump to content

[help] C# Replace

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
Darkco

Darkco

    Newbie

  • Members
  • PipPip
  • 13 posts
Hey,

So im currently working on a blackjack app.
As we know Ace can have 2 values which are 1 (when beyond 21) or 10 (under 21)

So im currently working on the card counter (counts your value of the cards)
But I cant figure out the ace thingy

Any ideas ?

Thanks

-Darkco

Edited by Darkco, 29 December 2009 - 03:17 PM.
grammar


#2
charless

charless

    Newbie

  • Members
  • PipPip
  • 14 posts
try this:
PlayerCard1.Image = Player_Card2.Image.Clone();


#3
Darkco

Darkco

    Newbie

  • Members
  • PipPip
  • 13 posts
That didnt work and even if it does it will only clone the card so you will always have 2 of the same cards.

Iv fixed the part where it will give you 2 of the same cards by just putting 2 random strings in it, I learned that the Random number is a default seed from the clock so it will always give the same cards in that one sec.

Anyway now I have to find a way to replace PlayerCard1 with Player_Card2 at the end of the loop. (Not byusing PlayerCard1 = Player_Card2; )

#4
charless

charless

    Newbie

  • Members
  • PipPip
  • 14 posts
that what this does:
PlayerCard1.Image = Player_Card2.Image.Clone();
That code will replace(should) replace card with card 2, when put at end of the loop (or anywhere i guess)

#5
Darkco

Darkco

    Newbie

  • Members
  • PipPip
  • 13 posts
it will give this error:

Error	1	Cannot implicitly convert type 'object' to 'System.Drawing.Image'. An explicit conversion exists (are you missing a cast?)	C:\Users\Darkco\Documents\Visual Studio 2008\Projects\BlackJack\BlackJack\Form1.cs	121	37	BlackJack

And it have to reset when you click the button(statement) again otherwise you will never get a new PlayerCard1

#6
charless

charless

    Newbie

  • Members
  • PipPip
  • 14 posts
oh ya, sorry bout that, this should work, I just tested:
PlayerCard1.Image = (Image)Player_Card2.Image.Clone();

#7
Darkco

Darkco

    Newbie

  • Members
  • PipPip
  • 13 posts
Well that didnt work aswell but I figured out already had to modify a little bit of my code :)

God i love msdn ^^

#8
charless

charless

    Newbie

  • Members
  • PipPip
  • 14 posts
Well that's weird that it didn't work, but at least you got your code working :)
Good luck on your app :D