/* AUTHOR: Sandy Bartlett COURSE: SI 543 PROJECT: OO programming DUE DATE: Feb. 11, 2002 SUBMISSION DATE: Feb. 11, 2002 SUMMARY A representation of an abstraction of a plant. INPUT none OUTPUT none CLASS HIERARCHY Object - Plant ASSUMPTIONS none */ import java.awt.*; public abstract class Plant { private String name; private int age; private boolean poisonous; private boolean edible; public Plant() { name = "Green thing"; } // default constructor // a baby plant public Plant(String name) { this.name = name; } // constructor with name only // a possibly poisonous baby plant public Plant(String name, boolean poisonous) { this.name = name; this.poisonous = poisonous; } // constructor with name and poisonous // a possibly poisonous and edible baby plant public Plant(String name, boolean poisonous, boolean edible) { this.name = name; this.edible = edible; this.poisonous = poisonous; } // constructor with name and poisonous and edible public Plant(String name, int age) { this.name = name; if (age >= 0) this.age = age; else age = 1; } // constructor with everything public Plant(String n, int a, boolean p, boolean e) { name = n; poisonous = p; edible = e; if (a >= 0) age = a; else age = 1; } // constructor with everything public abstract void draw(Graphics g); public int getAge() { return age; } //getAge public void setAge(int newAge) { if (newAge > age) // a plant can't get younger age = newAge; } // setAge public String getName() { return name; } // getName public boolean isPoisonous() { return poisonous; } // isPoisonous public boolean isEdible() { return edible; } // isEdible } // Plant