Created
June 1, 2013 02:51
-
-
Save kevindoran/5689125 to your computer and use it in GitHub Desktop.
Dragon class with inner speed calculator. This class is used to demonstrate aspects of Java serialization.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Dragon implements Serializable { | |
private static final long serialVersionUID = 1L; | |
private double wingSpan; | |
private String name; | |
private SpeedCalculator speedCalculator = new SpeedCalculator(); | |
public Dragon(double wingSpan, String name) { | |
// Input checks. For example, insuring wing size is greater than zero. | |
this.wingSpan = wingSpan; | |
this.name = name; | |
} | |
public double getWingSpan() { | |
return wingSpan; | |
} | |
public double getSpeed() { | |
double speed = speedCalculator.calculate(wingSpan); | |
return speed; | |
} | |
public String getName() { | |
return name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment