0

I'm creating a card game based on a Client Server communication, where the server (TV) shuffles and deals cards to players - clients (Android phones). I'm struggling with exactly how to set the source image for my cards, client-side. As the client I'm receiving the cards in a string array (eg. [C1,C2,C3,C4,C5]), note that in resources the image files are named exactly as they appear in that string (C = Clubs, D = Diamonds .. from 1 to 13). how should I do this ? I want to use the String Array in such a way that I can extract a single string and by using know which of the images I need to set as a source.

P.S I know I can use a switch with 52 cases for each source, but I'm sure there's a better way of doing things.

2
  • stackoverflow.com/a/4313064/2435402 should be what you're looking for. Wrapping this implementation inside a helper class of some sort gives a decent OOP approach. i.e. CardHelper.getCardFromString('...') would return an instance of a Card. OOP possibilities are endless and that's the fun part :) Commented Mar 17, 2016 at 14:18
  • Thanks for the reference, it helped. Commented Mar 17, 2016 at 14:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.