Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How should I go about programming this?

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How should I go about programming this?

    I am programming a certain card game. I have 7 cards in my hand like "7D" is 7 of diamonds. I want to program a method that gives me an ArrayList<String> which gives a list of the cards with the same number like "7H, 7D". I'm stuck on what exactly on how to go about doing it. Does anyone have any suggestions or reference I could use?


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: How should I go about programming this?

    Use the String charAt() method to obtain the '7' from "7D". Then use it to build up the strings you add to the array.

    Your code will be much more expressive if you write a Card class to model a card, and not use strings. Strings *can* be used to describe anything: but their generality is their weakness if you are interested in the specific behaviour of cards.

Similar Threads

  1. Polymorphism Java Programming HELPP P.S. I am a beginner in Java Programming
    By judemartin99 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 20th, 2013, 02:21 PM
  2. Linked Lists Java Programming HELPP P.S. I am a beginner in Java Programming
    By judemartin99 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 20th, 2013, 02:19 PM
  3. Blackjack programming error (programmer is new to programming)
    By JSingh in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 27th, 2012, 09:13 PM
  4. android programming vs game programming using java
    By vgoel38 in forum Android Development
    Replies: 4
    Last Post: September 8th, 2012, 05:48 PM
  5. Replies: 0
    Last Post: December 12th, 2011, 03:17 PM