Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TriPrism<T extends Number> {
- // Private variables for the dimensions of the prism
- private T length;
- private T base;
- private T height;
- // Getters and setters for length
- public T getLength() {
- return length;
- }
- public void setLength(T length) {
- this.length = length;
- }
- // Getters and setters for base
- public T getBase() {
- return base;
- }
- public void setBase(T base) {
- this.base = base;
- }
- // Getters and setters for height
- public T getHeight() {
- return height;
- }
- public void setHeight(T height) {
- this.height = height;
- }
- // Calculate the volume of the triangular prism
- public double calculateVolume() {
- return length.doubleValue() * 0.5 * base.doubleValue() * height.doubleValue();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment