Results 1 to 2 of 2
  1. #1
    scheffetz is offline Member
    Join Date
    Mar 2011
    Posts
    13
    Rep Power
    0

    Default ArrayList with Objects the right approach?

    Hello,

    I am making a memory match game for my java class. I want my game to have a twist that makes it a bit different than the classic memory match game.

    My concept is to match by association. For example, i might use country flags that you would have to match to the country names. I would be storing everything as jpg images, even the names.

    Where I am running into problems is matching 2 pictures that have different names.


    What I planned to implement was an ArrayList of Objects. Each object would store the picture reference and a category. The 2 associated pictures would have the same category, and I could match them using that since the jpg names would be different.


    Does this logic sound good? Am I on the right path?

    Or should I think about using a different approach?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default

    Could you use a Map as well to map the categories to a Pair object (possibly), which would hold both of your Objects that are related?

    Or, a Map of jpg names that maps to a Category, which contains both related jpgs?
    That way you can easily get from a filename to a category and find the related filename...

    This is all off the top of my head, of course.

Similar Threads

  1. help with saving objects in ArrayList
    By anghel.michael in forum New To Java
    Replies: 4
    Last Post: 02-22-2011, 09:09 PM
  2. Help with objects in ArrayList
    By BiteMuncher in forum New To Java
    Replies: 7
    Last Post: 02-21-2011, 11:55 AM
  3. Retrieving specific objects from ArrayList
    By soketti in forum New To Java
    Replies: 49
    Last Post: 10-29-2009, 07:10 AM
  4. ArrayList with different objects? Help
    By xtrmi in forum New To Java
    Replies: 4
    Last Post: 02-27-2009, 08:51 PM
  5. Opinions on best approach for objects
    By spikey in forum Advanced Java
    Replies: 1
    Last Post: 04-11-2008, 05:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •