Efficient way to keep referencing a class in multiple linked java classes? -


suppose in eclipse have 3 packages following classes in each:

packages: classes

head: head.java

body: arms.java

legs: feet.java

i want define class info in brain.java , pass through methods other classes (arms.java , feet.java) , update contents of info.

class info {     // vars such bools,ints,strings } 

for example, have updatearms method defined in arms.java. want following in brain.java:

arms.updatearms( info ); 

i having trouble finding how first define class behaves way, , secondly how pass parameter linked class.

first, should learn java naming convention.

for example, package should head, , class should head.

go design: in oop, see program interactions between object instances.

in example, may like:

class arm {     void moveup(someinfo info) {         ...     } }  class brain {     private arm leftarm;     private arm rightarm;      void reachforward() {         rightarm.moveup(...);     }      void connectleftarm(arm arm) {         this.leftarm = arm;     }     //.... }  class body {     brain brain;     arm leftarm;     arm rightarm;     public body() {         this.brain = new brain();         this.leftarm = new arm();         this.rightarm = new arm();         this.brain.connectleftarm(this.leftarm);         this.brain.connectrightarm(this.rightarm);     } } 

i wish demonstrate difference of way of thinking.

if start used way oop see things, can take next step in refining design (e.g. different design pattern)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -