Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Dist/Speed Function Question. (http://www.chiefdelphi.com/forums/showthread.php?t=100881)

JohnFogarty 22-01-2012 13:07

Dist/Speed Function Question.
 
For this year's competition we are going to have a shooter that has a sensor that reads how far it is from the goal and then by means of a predetermined array select the appropriate speed setting.
The only problem is the set speed method requires a double and I'm not sure how to make an array of doubles.
it doesn't seem to be simply,

double SPEED = new double[];

I was wondering if I was going to have to use an ArrayList to achieve my goal.

Spex_guy 22-01-2012 16:28

Re: Dist/Speed Function Question.
 
There are two ways of doing this. If you can determine a mathematical function, use that. Otherwise, try this:
Code:

final double[] SPEED = {double1, double2, double3...};
The reason your compiler didn't like the line you posted is because of syntax. It should have looked like this:
Code:

double[] SPEED = new double[SIZE];
I don't recommend using an ArrayList as they use a lot more memory than you need and they require objects, not primitives.


All times are GMT -5. The time now is 22:20.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi