public class WoodenColumn { private double height; //inches private double width; //inches private double expectedLoad; //pounds public int count; //number of columns public WoodenColumn() { height = 8 * 12; width = 3.625; expectedLoad = 100; //100 psi } public WoodenColumn(double height, double width, double expectedLoad) { this.height = height; this.width = width; this.expectedLoad = expectedLoad; } public double getHeight() { return height; } public double getWidth() { return width; } public double getExpectedLoad() { return expectedLoad; } public boolean isTooSlender() { double slendernessLimit = 50; if((this.getHeight()/this.getWidth()) <= slendernessLimit) { return false; } else { return true; } } public boolean willBuckle() { double area = this.getWidth() * this.getWidth(); double modusOfElasticity = 1700000; double bucklingRequirement = (0.3*modusOfElasticity*area) / ((this.getHeight()/this.getWidth())*(this.getHeight()/this.getWidth())); if((getExpectedLoad() <= bucklingRequirement)) { return false; } else { return true; } } public boolean willCompress() { double maximumStress = 1450; double area = this.getWidth() * this.getWidth(); if(getExpectedLoad() <= (area * maximumStress)) { return false; } else { return true; } } public boolean isSafe() { if(isTooSlender() || willBuckle() || willCompress()) { return false; } else { return true; } } public boolean equals() { if(this.height == getHeight() && this.width == getWidth() && this.expectedLoad == getExpectedLoad()) { return true; } else { return false; } } public String toString() { return "(" + (this.getHeight()) + ", " + this.getWidth() + ", " + this.getExpectedLoad() + ")"; } public static int numInstances(int count) { count++; return count; } public static WoodenColumn minStandardColumn(double height, double expectedLoad) { double nominalWidth = 0.625; WoodenColumn newColumn = new WoodenColumn(height, nominalWidth, expectedLoad); while(!newColumn.isSafe()) { nominalWidth++; } return newColumn; } }