/** * Author: Josiah Yoder et al. * Class: SE1011-021 * Lesson: Week 6, Day 1 */ /* * A spherical object */ public class BeachBall { // Attributes private double radiusCm; private double volumeCm3; private Color color; public BeachBall() { radiusCm = 1.0; } public BeachBall(double radiusCm, double volumeCm3){ this.radiusCm = radiusCm; this.volumeCm3 = volumeCm3; } public BeachBall(double radiusCm, Color color){ this.radiusCm = radiusCm; this.color = color; } public BeachBall(double radiusCm, double volumeCm3, Color color){ this.radiusCm = radiusCm; this.volumeCm3 = volumeCm3; this.color = color; } public void setVolume(double volumeCm3) { this.volumeCm3 = volumeCm3; } // Methods public double getPercentInflated() { double maxVolumeCm3 = (4.0/3.0)*Math.PI*Math.pow(radiusCm,3); return volumeCm3/maxVolumeCm3*100; } }