Skip to content

Instantly share code, notes, and snippets.

@kikoso
Last active January 30, 2017 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikoso/7f5b09b7f804653729760610c4921604 to your computer and use it in GitHub Desktop.
Save kikoso/7f5b09b7f804653729760610c4921604 to your computer and use it in GitHub Desktop.
Immutable Star
public final class Star {
/**
* Final and private attributes
*/
private final double mass;
private final String name;
private final Date dateOfDiscovery;
public Star (double aMass, String aName, Date aDateOfDiscovery) {
mass = aMass;
name = aName;
dateOfDiscovery = new Date(aDateOfDiscovery.getTime());
}
public double getMass() {
return mass;
}
public String getName() {
return name;
}
public Date getDateOfDiscovery() {
return new Date(dateOfDiscovery.getTime());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment