Hi,
I'm writing a small program to simulate a projectile moving through air in a gravitational field.
I have several classes for vectors, the gravitational field, and the projectile itsself.
However, when constructing any of these objects in the main method, I get a "cannot find symbol" error, despite the fact I am calling on a valid constructor, and all the files are in the same directory.

Here is my main method, and an example of one of the classes:

Main method:

import java.util.*;

public class ProjectileTest
{
	
public static void main(String[] args)
{
	Vector initPosition = new Vector(0,20);
	Vector initAcceleration = new Vector(0,0);
	Vector initVelocity = new Vector(10,0);
	double initdragCoeff = 0.002;
	double mass = 0.5;
	double deltatime = 0.05;
	
	PlanetField Earth = new PlanetField();
	Projectile Ball  = new Projectile(mass, initPosition, initAcceleration, initVelocity, initdragCoeff);
	
	do{
		System.out.println(Ball.position);
		Ball.update(deltatime, Earth);
	} while (Ball.position.GetY() >= 0);
}
}

Here is the PlanetField class I'm trying to invoke:

public class PlanetField{
/**
 * Representing the Gravitational field due to a massive object ( planet). Two pieces of informtion are
 * stored about the planet, it's mass and radius. SI units are used througout.
 *
 * @author  Alex Finch
 * @version 1.0
 */
    private double Mass; // Mass of planet
    private double Radius; // Radius of Planet
    final private double  G=6.6732E-11; // Gravitational constant
    /**
     *  Constructor with two inputs, the mass and radius of the planet.
     *
     * @param Min Mass of planet.
     * @param Rin Radius of planet.
     */
    public PlanetField(double Min, double Rin){
        Mass=Min;
        Radius=Rin;
    }
    
    public PlanetField(){
    	    Mass=5.9742E24;
    	    Radius=6.3781E6;
    }
    
    /**
     * Return acceleration due to gravity a height h above the planet's surface.
     * @param h height above planet in metres.
     * @return acceleration.
     */
    public double Acceleration(double h){
        // planet
        return (-1.0*G*Mass/(Radius+h)/(Radius+h));
    }
    /**
     * Return vector representing acceleration due to gravity at a given position
     * assume coordinate system as origin at surface of planet with y axis vertical
     *
     * @param position where acceleration is to be calculated
     * @return acceleration as a vector
     */
    public Vector Acceleration(Vector position){
        // return acceleration due to gravity a
        // position vector, assumed to have
        // (0,0) at surface of planet
	double r=position.GetY();
        return new Vector(0.0,-1.0*G*Mass/(Radius+r)/(Radius+r));
    }
    /**
     * Returns a string describing the planet
     * @return the descriptive string
     */
    public String toString(){
        return ("Mass = "+Mass+" kg, Radius = "+Radius+" metres ");
    }
}

I've even sent this to friends to ask them to compile on their computers, and they can do so without trouble, it seems to be something to do with my computer. I'm using JDK 6 update 18.

Thankyou for any help you can provide.

Recommended Answers

All 2 Replies

Tell your friends they are no friends at all, otherwise they would tell you that you are missing Vector import at the start of PlanetField, that you missing declaration of variable position so you can access GetY method from line 50 and also that return statement on line 51 doesn't make any sense

commented: Lol. +4

Actually it turned out the class path hadn't seen set up properly, so it was only "seeing" my main method, and none of the classes.

I only posted one example of the class I was having problem, not all of them, hence the nonsensical statements you noticed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.