Need help on returning an array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tzesiong
    New Member
    • Oct 2007
    • 3

    Need help on returning an array

    Hi all.

    I've encountered a problem here.



    public double getValue() {
    return phase1.getBound ary(Space3D.Bou ndaryPeriodicSq uare(,,));
    }

    public void setValue(double d) {

    phase1.setBound ary(new Space3D.Boundar yPeriodicSquare (d,d,d));

    diaTextField.se tText(toString( ).valueOf((floa t)phase1.getCol lisionDiameter( )));
    display1.repain t();




    Please refer to the words in bold. esp, return phase1.getBound ary(Space3D.Bou ndaryPeriodicSq uare(,,));

    the program is not running becuase of this instance.
    i know this is because i am trying to get length, breadth and height into the getBoundary.

    Should i use double ?

    any idea anyone?

    thanks a lot in advance
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by tzesiong
    Hi all.

    I've encountered a problem here.



    public double getValue() {
    return phase1.getBound ary(Space3D.Bou ndaryPeriodicSq uare(,,));
    }

    public void setValue(double d) {

    phase1.setBound ary(new Space3D.Boundar yPeriodicSquare (d,d,d));

    diaTextField.se tText(toString( ).valueOf((floa t)phase1.getCol lisionDiameter( )));
    display1.repain t();




    Please refer to the words in bold. esp, return phase1.getBound ary(Space3D.Bou ndaryPeriodicSq uare(,,));

    the program is not running becuase of this instance.
    i know this is because i am trying to get length, breadth and height into the getBoundary.

    Should i use double ?

    any idea anyone?

    thanks a lot in advance
    1.) Do not use bold tags for posting code. Use code tags instead.
    2.) What are the arguments to the BoundaryPeriodi cSquare method in your getValue method?

    Comment

    • tzesiong
      New Member
      • Oct 2007
      • 3

      #3
      public static class BoundaryPeriodi cSquare extends Boundary implements Space.Boundary. Periodic {
      public BoundaryPeriodi cSquare() {this(Default.B OX_SIZE,Default .BOX_SIZE,Defau lt.BOX_SIZE);}
      public BoundaryPeriodi cSquare(Phase p) {this(p,Default .BOX_SIZE,Defau lt.BOX_SIZE,Def ault.BOX_SIZE); }
      public BoundaryPeriodi cSquare(Phase p, double lx, double ly, double lz) {super(p);dimen sions.x=lx; dimensions.y=ly ; dimensions.z=lz ; updateDimension s();}
      public BoundaryPeriodi cSquare(double lx, double ly, double lz) {super();dimens ions.x=lx; dimensions.y=ly ; dimensions.z=lz ; updateDimension s();}
      public Space.Boundary. Type type() {return Boundary.PERIOD IC_SQUARE;}
      private static Space.Tensor zilch = new Tensor();
      private final Vector temp = new Vector();
      private final Vector dimensions = new Vector();
      private final Vector dimensionsCopy = new Vector();
      private final Vector dimensionsHalf = new Vector();
      public final Space.Vector dimensions() {return dimensionsCopy; }
      public Space.Vector randomPosition( ) {
      temp.x = dimensions.x*Si mulation.random .nextDouble();
      temp.y = dimensions.y*Si mulation.random .nextDouble();
      temp.z = dimensions.z*Si mulation.random .nextDouble();
      return temp;
      }


      Sorry. I hope this is the one you are looking for.

      Anyway, i am just confused. How am i supposed to get the parameters into my getValue.

      Thanks for your help.

      I am sorry if its lengthy.

      Raymond

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by tzesiong
        public static class BoundaryPeriodi cSquare extends Boundary implements Space.Boundary. Periodic {
        public BoundaryPeriodi cSquare() {this(Default.B OX_SIZE,Default .BOX_SIZE,Defau lt.BOX_SIZE);}
        public BoundaryPeriodi cSquare(Phase p) {this(p,Default .BOX_SIZE,Defau lt.BOX_SIZE,Def ault.BOX_SIZE); }
        public BoundaryPeriodi cSquare(Phase p, double lx, double ly, double lz) {super(p);dimen sions.x=lx; dimensions.y=ly ; dimensions.z=lz ; updateDimension s();}
        public BoundaryPeriodi cSquare(double lx, double ly, double lz) {super();dimens ions.x=lx; dimensions.y=ly ; dimensions.z=lz ; updateDimension s();}
        public Space.Boundary. Type type() {return Boundary.PERIOD IC_SQUARE;}
        private static Space.Tensor zilch = new Tensor();
        private final Vector temp = new Vector();
        private final Vector dimensions = new Vector();
        private final Vector dimensionsCopy = new Vector();
        private final Vector dimensionsHalf = new Vector();
        public final Space.Vector dimensions() {return dimensionsCopy; }
        public Space.Vector randomPosition( ) {
        temp.x = dimensions.x*Si mulation.random .nextDouble();
        temp.y = dimensions.y*Si mulation.random .nextDouble();
        temp.z = dimensions.z*Si mulation.random .nextDouble();
        return temp;
        }


        Sorry. I hope this is the one you are looking for.

        Anyway, i am just confused. How am i supposed to get the parameters into my getValue.

        Thanks for your help.

        I am sorry if its lengthy.

        Raymond
        Why did you post all that code anyway. I didn't ask for that. And you did not use code tags again for posting code. It helps to actually read the replies you get if you want get help.
        I was asking you what you wanted to achive by this line:
        [CODE=java] return phase1.getBound ary(Space3D.Bou ndaryPeriodicSq uare( ,,));[/CODE]
        You did not supply any arguments to the BoundaryPeriodi cSquare method. All those commas you have in there without the actual parameters is simply invalid Java code and won't compile.

        Comment

        • tzesiong
          New Member
          • Oct 2007
          • 3

          #5
          Originally posted by r035198x
          Why did you post all that code anyway. I didn't ask for that. And you did not use code tags again for posting code. It helps to actually read the replies you get if you want get help.
          I was asking you what you wanted to achive by this line:
          [CODE=java] return phase1.getBound ary(Space3D.Bou ndaryPeriodicSq uare( ,,));[/CODE]
          You did not supply any arguments to the BoundaryPeriodi cSquare method. All those commas you have in there without the actual parameters is simply invalid Java code and won't compile.

          with that line, [CODE=java] return phase1.getBound ary(Space3D.Bou ndaryPeriodicSq uare( ))

          public void setValue(double d) {
          phase1.setBound ary(new Space3D.Boundar yPeriodicSquare (d,d,d));

          diaTextField.se tText(toString( ).valueOf((floa t)phase1.getBou ndary());
          display1.repain t(); [/CODE]

          actually , my idea was this :

          i wish to return value of a 3 by 1 array which i got from setValue, to getValue.
          but i dont know how to get the values in . i knew the commas are invalid. and the error that i got from line 1 is : cannot convert to double.

          Thanks a lot.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by tzesiong
            with that line, [CODE=java] return phase1.getBound ary(Space3D.Bou ndaryPeriodicSq uare( ))

            public void setValue(double d) {
            phase1.setBound ary(new Space3D.Boundar yPeriodicSquare (d,d,d));

            diaTextField.se tText(toString( ).valueOf((floa t)phase1.getBou ndary());
            display1.repain t(); [/CODE]

            actually , my idea was this :

            i wish to return value of a 3 by 1 array which i got from setValue, to getValue.
            but i dont know how to get the values in . i knew the commas are invalid. and the error that i got from line 1 is : cannot convert to double.

            Thanks a lot.
            Hold on. You are no longer making much sense.

            That setValue method does not return anything. It's return type is void.
            Now if you could answer these two questions:
            1.) What return type is the getBoundary method?
            2.) What parameters does the Space3D.Boundar yPeriodicSquare method expect?

            Comment

            Working...