Skip to content

Instantly share code, notes, and snippets.

@kevindoran
Created June 1, 2013 02:51
Show Gist options
  • Save kevindoran/5689125 to your computer and use it in GitHub Desktop.
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.
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