Why can't java handle Strings sanely?

Jun 26, 2007 15:16

I am writing a java based blackjack program for fun and kicks as well as something to put down on my resume for programming experience.

Basically I decided to write a deck object with a cards array that is 2 dimensional aka double scripted. So I have the following:

public class Deck {

/** Creates a new instance of Deck */
public Deck()
{
}

private static void CreateCards( String args[] ) // TODO look up proper java rules on caps
{

// Java uses array objects so create object constructor then set limits
// create Cards object with 2 dimensions.
char Cards[ ][ ];

// initialize Cards array constructor
// for 1st dimension 0 = spades, 1 = clubs, 2 = hearts, 3 = diamond
// for second dimension 0 = Ace, 11 = jacks, 12 = queen, 13 = king
Cards = new char[4][ ]; // 4 rows for each card class

Cards[ 0 ] = new char[13]; // 13 for each row as described above
Cards[ 1]= new char[13];
Cards[ 2 ]= new char[13];
Cards[ 3 ] = new char[ 13];
}

This looks ugly.

What I want is

string Cards[][]; Where I can assign string values. THe code gets alot uglier as I progress with things like Cards[collumn][row]= sK for King of Spades. I would prefer it to be Cards[spades][king]. Could enumerators work?

I think for a first project on my own in over a year since I have written any java code its best to pick something simplier. I have forgotten so much in a year and its frightening as I have to lookup the proper way to do a simple if statement in the right syntax.

java, programming, work

Previous post Next post
Up