Question: How do I get rid of hiding class error for double a, b, c? Example: [ERROR] Ellipsoid.java:94:31: 'a' hides a field. [HiddenField] import java.text.DecimalFormat; /**
How do I get rid of hiding class error for double a, b, c?
Example:
[ERROR] Ellipsoid.java:94:31: 'a' hides a field. [HiddenField]
import java.text.DecimalFormat; /** main. */ public class Ellipsoid /** *Prints encoded message *@param args Command line arguments - not used. */
{ /** main. *@param args Command line arguments - not used. */ private String label = ""; private double a = 0; private double b = 0; private double c = 0; /** main. * @param an fff * @param bn ddd * @param cn dddd * @param labelIn */
public Ellipsoid(String labelIn, double an, double bn, double cn) /** * @param an fff * @param bn ddd * @param cn dddd * @param labelI */ { setLabel(labelIn); setA(an); setB(bn); setC(cn); }
/** return. * * @return label */ public String getLabel() { return label; }
/** return. * * @param labela dree * @return if String not null * return true */ public boolean setLabel(String labela) /** * @param labela dr */ { if (label != null) { this.label = label.trim(); return true; } else { return false; } } /** return. * * @return a */ public double getA() { return a; }
/** return. * * @param an fff * @return if a>0 is true */ public boolean setA(double a) /**return. * * @param an dff * */ { if (a > 0) { this.a = a; return true; } else { return false; } } /**return. * * @return b */ public double getB() { return b; }
/**return. * * @param bn gggf * @return true if b>0 */ public boolean setB(double b) /**return. * * @param bn dfff * */ { if (b > 0) { this.b = b; return true; } else { return false; } } /**return. * * @return c */
public double getC() { return c; }
public boolean setC(double c) /** return. * @param c */ { if (c > 0) { this.c = c; return true; } else { return false; } } /**return. * * @return volume calculated */ public double volume() { return (4 * Math.PI * a * b * c) / 3; }
/**return. * * @return calculated surfaceArea */ public double surfaceArea() { double sa = (Math.pow((a * b), 1.6) + Math.pow((a * c), 1.6) + Math.pow((b * c), 1.6)) / 3; sa = 4 * Math.PI * Math.pow(sa, (1.0 / 1.6)); return sa; }
/**return. * * @return String object */ public String toString() { DecimalFormat decimalFormat = new DecimalFormat("#,##0.0###"); return "Ellipsoid \"" + label + "\" with axes a = " + getA() + ", b = " + getB() + ", c = " + getC() + " units has: \tvolume = " + decimalFormat.format(volume()) + " cubic units" + " \tsurface area = " + decimalFormat.format(surfaceArea()) + " square units"; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
