Implement a class Moth that models a moth flying across a straight line. The moth has a position, the distance from a fixed origin. When the moth moves toward a point of light, its new position is halfway between its old position and the position of the light source. Supply a conductor
public Moth(double initialPosition)
and methods
public void moveToLight(double lightPosition)
public double getPosition
1
Expert's answer
2013-07-23T11:48:35-0400
public class Test { publicstatic void main(String[] args) { Mothmoth1=new Moth(1.0); Mothmoth2=new Moth(3.0);
Comments
Leave a comment