Java - how to make class 1 and class 2 both know about each other? -


I have a program in the middle of the program that means imitating bugs to find food. In short I have a There is a grid (a world) in which there are bugs, obstacles and food of various energy values. Each bug will look in every direction, find the closest food within its "close look" and take a cell instead to move in a random direction instead.

I have 3 clauses:

  • Abig

  • Awesome

  • Main

Ebug and Everland clearly populate a grid to transfer food and obstacles, food to understand, a bug etc. Includes all methods, and the main class controller that creates a world creates many bugs based on user input and adds them to the world.

My question is this:

Is the bug a better way of getting to know the world, whenever its bugs are known in the world, in every function world Does the context of this require a bug in the bug?

I currently have an array list of bugs inside world class and then 2D array is required in the bug class in the function.

Sorry for the long explanation, it was not sure

"post-text" itemprop = Thanks for "text"

>

I For every bug objectation, the context of a world example will be passed either by the bug creator or in a setter method, in this way it is known about every bug frequency that it is an example of the world and can ask about some things ( Such as ask for food ...).

I will not make the world a singleton (see definition :). As there is no need to limit yourself to exactly 1 instance of the world and there is no use. When unsuitable singleton patterns are used, you can limit the test qualification of your design, start with issues of micro threading (and classing) ...


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -