Results 1 to 3 of 3
  1. #1
    lolmister is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default affecting other classes

    I am trying to make a game. I have my main class, which has multiple objects of another class, I'll call it bobby. I want bobby to be able to call methods, or change variables in the main class. I don't know what this is called, so if there is another post like this I am sorry.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default Re: affecting other classes

    Pass the other class a reference to the "main" class, say in its constructor, and save it in a class variable for any methd to use. The other class can use that reference to call the "main" class
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    lolmister is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

Similar Threads

  1. Association Classes for these classes
    By kevinkhan in forum New To Java
    Replies: 9
    Last Post: 03-21-2012, 05:22 PM
  2. Classes Help!!! two classes with object question.
    By stuckonjava in forum New To Java
    Replies: 16
    Last Post: 02-10-2012, 01:39 AM
  3. Use classes inside of other classes
    By BlankFile in forum New To Java
    Replies: 2
    Last Post: 02-06-2012, 01:51 PM
  4. Replies: 2
    Last Post: 03-03-2010, 07:30 AM
  5. Using a JAR from other classes
    By Joe2003 in forum Advanced Java
    Replies: 1
    Last Post: 01-02-2008, 07:08 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
  •