Question
Hi, I created an Ellipsoid.java program with an equation. I am using jGrasp and I need help writing these methods for my EllipsoidList.java file(Code included)
Hi, I created an Ellipsoid.java program with an equation. I am using jGrasp and I need help writing these methods for my EllipsoidList.java file(Code included)
:
Ellipsoid.Java:
import java.text.DecimalFormat; /** * Program that formualtes an ellipsoid. This program takes input from the user. * * Project 4. * @author david * @version 02/05/2020. */ public class Ellipsoid { //Fields private String label = ""; private double a = 0; private double b = 0; private double c = 0; //constructor /** *@param labelIn establish the label *@param aIn establishes a axes. *@param bIn establishes b axes. *@param cIn establishes c axes. */ public Ellipsoid(String labelIn, double aIn, double bIn, double cIn) { setLabel(labelIn); setA(aIn); setB(bIn); setC(cIn); } //Methods /** *@return getLabel */ public String getLabel() { return label; } /** * * @param labelIn this retrieves a label. * @return setLabel */ public boolean setLabel(String labelIn) { if (labelIn == null) { return false; } else { label = labelIn.trim(); return true; } } /** * * @return getA */ public double getA() { return a; } /** * * @param aIn this returms a boolean. * @return setA */ public boolean setA(double aIn) { if (aIn > 0) { a = aIn; return true; } else { return false; } } /** * * @return getB */ public double getB() { return b; } /** * * @param bIn this returms a boolean. * @return setB */ public boolean setB(double bIn) { if (bIn > 0) { b = bIn; return true; } else { return false; } } /** * * @return getC */ public double getC() { return c; } /** * * @param cIn this returna a boolean. * @return setC */ public boolean setC(double cIn) { if (cIn > 0) { c = cIn; return true; } else { return false; } } /** * * @return volume */ public double volume() { double volume = ((4 * Math.PI * a * b * c) / 3); return volume; } /** * *@return surfaceArea */ public double surfaceArea() { double thePowers = (Math.pow((a * b), 1.6) + Math.pow((a * c), 1.6) + Math.pow((b * c), 1.6)) / 3; double surfaceArea = 4 * Math.PI * Math.pow(thePowers, (1.0 / 1.6)); return surfaceArea; } /** * * @return toString */ public String toString() { DecimalFormat decimalFormat = new DecimalFormat("#,##0.0###"); return "Ellipsoid \"" + getLabel() + "\" with axes a = " + decimalFormat.format(a) + ", b = " + decimalFormat.format(b) + ", c = " + decimalFormat.format(c) + " units has: \tvolume = " + decimalFormat.format(volume()) + " cubic units" + " \tsurface area = " + decimalFormat.format(surfaceArea()) + " square units"; } }
EllipsoidList.Java:
import java.util.ArrayList; import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; import java.text.DecimalFormat; /** * Program that formualtes an ellipsoid. This program takes input from the user. * * Project 4. * @author david * @version 02/05/2020. */ public class EllipsoidList { private String list; private ArrayList ellipsoidList; /** * Create a TriangleList object. * constructor. * @param listIn for listName * @param ellipsoidListIn for ellipsoidList */ public EllipsoidList(String listIn, ArrayList ellipsoidListIn) { list = listIn; ellipsoidList = ellipsoidListIn; } //methods /** * @return the list name */ public String getName() { return list; //// } /** * @return the list name */ public int numberOfEllipsoids() { int numberOfEllipsoids = 0; if (ellipsoidList.size() == 0) { return 0; } else { return ellipsoidList.size(); } } /** * @return the list name */ public double totalVolume() { double total = 0; int index = 0; while (index The following six methods are new in Project 6 o getList: Returns the ArrayList of Ellipsoid objects the second field above) readfile: Takes a String parameter representing the file name, reads in the file, storing the list name and creating an ArrayList of Ellipsoid objects, uses the list name and the ArrayList to create an EllipsoidList object, and then returns the Ellipsoid List object See note #1 under Important Considerations for the EllipsoidListMenu App class (last page) to see how this method should be called o addEllipsoid: Returns nothing but takes four parameters (label, a, b, and c), creates a new Ellipsoid object, and adds it to the Ellipsoid List object (ie, adds it to the ArrayList of Ellipsoid objects in the Ellipsoid List object) o findEllipsoid: Takes a label of an Ellipsoid as the String parameter and retums the corresponding Ellipsoid object if found in the Ellipsoid List object; otherwise returns null. Case should be ignored when attempting to match the label deleteEllipsoid Takes a String as a parameter that represents the label of the Ellipsoid and returns the Ellipsoid if it is found in the Ellipsoid.ist object and deleted; otherwise returns null. Case should be ignored when attempting to match the label consider calling using findellipsoid in this method O editEllipsoid: Takes four parameters (label, a, b, and c), uses the label to find the corresponding the Ellipsoid object. If found, sets the a, b, and to the values passed in as parameters, and returns the Ellipsoid object. If not found, returns null. This method should not change the label
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started