2024_Programming_Training_D.../CS7 - Demo/Tree.java
2024-05-14 18:45:10 -04:00

33 lines
719 B
Java

public class Tree {
private String typeOfTree;
private double height;
private double width;
public Tree(String newTypeOfTree, double newHeight, double newWidth) {
typeOfTree = newTypeOfTree;
height = newHeight;
width = newWidth;
}
public String getTypeOfTree() {
return typeOfTree;
}
public double getHeight() {
return height;
}
public double getWidth() {
return width;
}
public void grow(double heightAdd, double widthAdd) {
height += heightAdd;
width += widthAdd;
}
public String toString() {
return "Type of Tree: " + typeOfTree + " Height: " + height + " Width: " + width;
}
}