Below is an attachment with two pages. "The UML diagram and instructions are on there also, so you can understand" *i need help with ShipTest.java, cause I can't get it to compile, mainly cause I haven't gotten much written cause I haven't complete Ship.java all the way.
So far, I have Ship.java written, but not 100% correctly, because I used bits an pieces from code I have written to build it up so it would compile, the returns are not exactly right.
The only real problem I am having with it, is the "double" 'timeToCrossEnglishChannel'.
/************************************************** * Name: Matt Spencer * Assignment: A04 **************************************************/ public class Ship { //fields private String name; private double speed; //constructors public Ship(String bName, double s) { name = bName; setSpeed(s); } //methods public String getName() { return name; } public double getSpeed() { return speed; } public void setName(String newName) { name = newName; } public void setSpeed(double s) { if (s >= 0) speed = s; } public double timeToCrossEnglishChannel(double s) { return speed * 2; } }
ShipTest.java is much worst, I can't figure out why it won't compile, it keeps putting an error on my "=" sign, for the line Ship myShip = new Ship();
/************************************************** * Name: Matt Spencer * Assignment: A04 **************************************************/ import java.util.Scanner; public class ShipTest { public static void main(String[] args) { Ship myShip = new Ship(); myShip.setName("Rob Roy"); } }
thanks for any help.