I messed up with my class assignment. Pl help me i did some so far.
File Ship
And file ShipTest// public class Ship { //fields private String name; private double speed; //constructors public Ship() { } //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; } }
So in File ship how to: Declare a public method called timeToCrossEnglishChannel.//import java.util.Scanner; public class ShipTest { public static void main(String[] args) { Ship myShip = new Ship(); myShip.setName("Rob Roy"); } }
It takes no parameter and returns the number of hours it takes to cross the channel. The return value is of type double.
and in File Shiptest how to: Create an instance of type Ship. Call the variable of type Ship paddleStreamer.
The name of the paddleStreamer is Rob Roy and the speed is 6 knots. Use this information to assign the fields.