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 4 of 4

Thread: In a class create an array list of elements of another class, help!

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default In a class create an array list of elements of another class, help!

    I have created class Square, boxes 1x1x1 with different properties like walls and doors etc. Doors can be open or closed.
    Now I need to create class of collections of these squares, class Dungeon. Each dungeon must have its own (ordinary) system of coordinates in the beginning in the square with most northern (x), western (y) and low(z) position. (so another squares will only have positive coordinates). Each square has to border at least with one another square. More, it may not be anything plased on (x,x,x).
    I also have to create "spaces", made by squares with open doors.

    I want to make a constructor in class Dungeon that will first create a new element of Square, give it zero-coordinates, then create new squares that will border with the previous in a direction that constructor will choose. (Is it a good idea and how to make it choose it?) While creating new squares I will get their coordinates and put it into array, also check that the coordinate will not be (x,x,x), where x- any integer.

    I am not sure about how to create spaces without making a new class, please if you have any ideas, help!

    https://sites.google.com/site/podzemelja/
    Last edited by LadyBelka; May 1st, 2011 at 05:06 PM.


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: In a class create an array list of elements of another class, help!

    Quote Originally Posted by LadyBelka View Post
    I am not sure about how to create spaces without making a new class, please if you have any ideas, help!
    ?? You said spaces are made by squares with open doors...

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: In a class create an array list of elements of another class, help!

    yes if they are neighbors and there is an open door between them, but they can be more than two, actually. The point is that you can freely go from any of them to any other in this spaces

  4. #4
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: In a class create an array list of elements of another class, help!

    You asked for help creating spaces without making a new class, but you say spaces are made by squares with open doors - which obviously suggests you can make spaces by using squares with open doors.

    I'm afraid I really don't understand your problem, or the relevance of your last post.

Similar Threads

  1. Replies: 2
    Last Post: January 22nd, 2011, 11:20 PM
  2. Replies: 0
    Last Post: December 1st, 2010, 06:10 AM
  3. How to create a new object of another class within a method
    By davie in forum Object Oriented Programming
    Replies: 1
    Last Post: April 16th, 2010, 05:53 PM
  4. Create a java small class for a bank account!!?
    By jon123 in forum Object Oriented Programming
    Replies: 2
    Last Post: March 24th, 2010, 11:00 AM
  5. need help with a list class
    By araujo3rd in forum Object Oriented Programming
    Replies: 1
    Last Post: February 25th, 2010, 07:58 PM