Classes
public class Dog {
// These are the state, just fields
private final Integer age;
private final Sex sex;
private final String name;
private final Double maxSpeed;
private final Breed breed;
// See section about constructors here
public Dog(Integer age, Sex sex, String name, Double maxSpeed, Breed breed) {
this.age = age;
this.sex = sex;
this.name = name;
this.maxSpeed = maxSpeed;
this.breed = breed;
}
// These are the behaviours, just methods
public String bark() {
// implementation
}
public Double run(Double distance) {
// implementation
}
// any more methods you want to access
}Links
Last updated