art Page A lai SpaceShipjava SpaceShipTestjava * @author moe222 public class Spa
ID: 3854879 • Letter: A
Question
art Page A lai SpaceShipjava SpaceShipTestjava * @author moe222 public class SpaceShip implements ComparablecSpaceShip>( E enum ShipType Scoutship, ScienceVessel, ConstructionVessel, Warshíp) private ShipType classification; String shipName; String captain; public Spaceship)t this.classification -ShipType.WarShip; this.shipName.-.. Disaster .. this.captain "Captain King of The Fist" public SpaceShip(ShipType classification, String shipName, String captai this.classificationclassification; this . shipName shipName ; this.captain = captain; bspaceshiptest.SpaceShip utput 3Explanation / Answer
Hi buddy, the problem is with the equals method.
1. you should access classification of the otherShip using dot operator (.). So, classification should be referred using otherShip.classification.
2. The method is not properly closed. There must be a bracket at the end of equals method. Correct equals method is
public boolean equals(SpaceShip otherShip ){
if(this.classification==otherShip.classific ation){
return true;
}
else{
return false;
}
}
Once you correct the formatting issue, everything else will be corrected.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.