public class Flower {
//Fields
private String kind;
private double cost; //what we paid for it
private double price; //what we sell it for
private int daysToLive;
// Constructors
public Flower(String kind, double cost, double price,
int daysToLive) {
this.kind = kind;
this.cost = cost;
this.price = price;
this.daysToLive = daysToLive;
}
//Accessors
public String getKind() {
return kind; }
public double getCost() {
return cost; }
public double getPrice() {
return price; }
public int getDaysToLive() {
return daysToLive; }
//Mutators
public void setPrice(double price) {
this.price = price;
}
public void age(int days) {
daysToLive = Math.max(0, daysToLive - days);
}
}