/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package pointtest; /** * * @author jcmtiernan */ public class MovingThing implements MovingThang{ double maxSpeedInMPH; LOCOMOTION kindOfLoco; public MovingThing(double maxSpeed, LOCOMOTION kindOfLoco) { this.setMaxSpeed(maxSpeed); this.setKindOfLoco(kindOfLoco); } public MovingThing(double maxSpeed, String kindOfLoco) { this.setMaxSpeed(maxSpeed); this.setKindOfLoco(kindOfLoco); } @Override public double getMaxSpeed() { return maxSpeedInMPH; } @Override public void setMaxSpeed(double maxSpeed) { if (maxSpeed < 0) { this.maxSpeedInMPH = -maxSpeed; } else { this.maxSpeedInMPH = maxSpeed; } } @Override public LOCOMOTION getKindOfLoco() { return kindOfLoco; } @Override public void setKindOfLoco(LOCOMOTION kindOfLoco) { this.kindOfLoco = kindOfLoco; } @Override public void setKindOfLoco(String nameOfLoco) { if (nameOfLoco.equalsIgnoreCase("WHEELS")) { this.kindOfLoco = LOCOMOTION.WHEELS; } else if (nameOfLoco.equalsIgnoreCase("FEET")) { this.kindOfLoco = LOCOMOTION.FEET; } else { this.kindOfLoco = LOCOMOTION.FINS; } } @Override public String toString() { return String.format(" has maximum speed of "+getMaxSpeed()+" locomotion type of "+getKindOfLoco()); } }