java 1 class or interface expected..please forgive me..i am begginer program who requires help. If you guys are able to do so..pin point the error and kind of error i am making. Thanks.
Here are my codes:
public class Vessel
{
private double xCoord;
private double yCoord;
private double velocity;
private double bearing;
public Vessel(double xCoord, double yCoord, double velocity, double bearing)
{
this.setXCoord(xCoord);
this.setYCoord(yCoord);
this.setVelocity(velocity);
this.setBearing(bearing);
}
public double getXCoord()
{
return xCoord;
}
public boolean setXCoord(double x)
{
boolean doSetXcoord = true;
return doSetXcoord;
}
public double getYCoord()
{
return yCoord;
}
public boolean setYCoord(double y)
{
if (y <= -1000.0 && y >= 1000.0)
{
return true;
}
else
{
return false;
}
}
public double getVelocity()
{
return velocity;
}
public boolean setVelocity(double v)
{
if (v <= 0.0 && v >= 600.0)
{
return true;
}
else
{
return false;
}
}
public double getBearing()
{
return bearing;
}
public boolean setBearing(double B)
{
if (b <= 0.0 && b >= 360.0)
{
return true;
}
else
{
return false;
}
}
public String toString
()
{
return "( X-Coordinate = " + xCoord + " Y-Coordinate = " + yCoord + "V-Velocity = " + velocity + " B-Bearing = " + bearing + " )";
}
public void display()
{
System.out.println("(" + this.xCoord + "," + this.yCoord + "," + this.velocity + "," + this.bearing + ")");
}
}
O yaa and here are the instruction that was given to me..if that helps to help me make understand.
In this assignment you will develop a Vessel class. The Vessel class will represent an ocean-going vessel rather than a freshwater boat. Its characteristics will be modeled as data members for its i) x- and y-coordinates, ii) its velocity, and iii) its direction.
The location of a Vessel object will be determined by the values of its x- and y-coordinates relative to an unspecified, fixed origin. Assume that the units of measure are kilometres. The velocity of a vessel will be stated as km/hour. The direction of the vessel will be measured in degrees using the trigonometric convention. All data members will store decimal values.
edit: added [code] tags ~ jayman9

New Topic/Question
Reply




MultiQuote




|