/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Creating Swimming pool class public class SwimmingPool { // constant private final float CAPACITY_CUBIC_FOOT = 7.48f; // instance variable private float lengthOfPool; private float widthOfPool; private float shallwoDeptOfPool; private float deepDepthOfPool; private float volume; private float capacity; // Constructor public SwimmingPool ( float length, float shallowEndDept, float deepEndDepth) { lengthOfPool = length; widthOfPool = width; shallowDeptOfPool = deepEndDept; } // instance methods public float volumeOfWater() { volume=0.5f*(lengthOfPool*widthOfPool)*(shallowDeptOfPool + deepDepthOfPool); return volume; } public float capacityOfPool() { capacity = volume *CAPACITY_CUBIC_FOOT; return capacity; } public float timeToFillPool (float rateOfFlow) { return (capacity / rateOfFlow) / 60.0f; } }