Question
Can someone help me with this? Files from the previous projects can be downloaded from the links below: Anon File Links: https://anonfiles.com/Ead1s2abzb/HeartShapedBoxListApp_java https://anonfiles.com/D2d6s3a9z1/HeartShapedBoxList_java https://anonfiles.com/C7d4s1a2z2/HeartShapedBox_java Google
Can someone help me with this?
Files from the previous projects can be downloaded from the links below: Anon File Links:
https://anonfiles.com/Ead1s2abzb/HeartShapedBoxListApp_java
https://anonfiles.com/D2d6s3a9z1/HeartShapedBoxList_java
https://anonfiles.com/C7d4s1a2z2/HeartShapedBox_java
Google Drive Links:
https://drive.google.com/file/d/1GaejdSKe0zzMR2a4BqIKBKLBmnEKRJsZ/view?usp=sharing, https://drive.google.com/file/d/1nShClclv0sbnqb4bBV9g0uqSOzJUbvwL/view?usp=sharing, https://drive.google.com/file/d/1tPPmaMjExPYEdMNisKSsHKXcbWnYW8_g/view?usp=sharing
Data Files for Testing:
https://drive.google.com/file/d/13K-PkNYLlv_kBDYyt4qDE2gjBXHBJQRV/view?usp=sharing, https://drive.google.com/file/d/1nOCAm0a3Edb8aCcMvyrDVwV7THEXibV3/view?usp=sharing
Thank you in advance!
Deliverables Your project files should be submitted to Web-CAT by the due date and time specified. You may submit your files to the skeleton code assignment until the project due date but sbould try to do this much earlier. The skeleton code assignment is ungraded, but it checks that your classes and methods are named correctly and that methods and parameters are correctly typed. The files you submit to skeleton code assignment may be incomplete in the sense that method bodies have at least a retum statement if applicable or they may be essentially completed files. In onder to avoid a late penalty for the project, you must submit your completed code files to Web-CAT no later than 11-59 PM on the due date for the completed code. If you are unable to submit via Web-CAT, you sbould e-mail your files in a zip file to your TA before the deadline. Files to submit to Web-CAT (all three files must be submitted together): - HeartShapedBox java - HeartShapedBoxList.java - HearShapedBoxListMenuApp.java A Heart Shaped Box has heart shaped top and bottom with height h. The heart shape, shown in the figure below, is composed of two half circles, each with radius r, and a square with sides of length 2r. The formulas are provided to assist you in computing return values for the respective methods in the HeartShapedBox class deseribed in this project. Formulas for area of heart shupe ( ANeart), lateral surface area (ALetrrat), toeal surface area (ATotat), and volume ( V ) are shown below where r is the nadius and h is the height (the distance between the top and bottom of the box), both of which will be read in. AHeart=r2+4r2ALateral=h(4r+2r)ATotal=2AHeart+ALateratV=hAHeart Specifications Overview: You will write a program this week that is composed of three classes: HeartShapedBox, HeartShapedBoxL ist, and HeartShapedBext istMenuApp, which presents a menu to the user with eight options and implements these options: (I) read input file (which creates a HeartShapedBoxList object), (2) print report, (3) print summary, (4) add a HearshapedBox object to the HeartShapedBoxList object, (5) delete a HeartShapedBox object from the HeartShapedBoxL ist object, (6) find a HeartShapedBox object in the HeartShapedBoxL ist object, (7) Edit a HeartShapedBox in the HeartShapedBoxList object, and (8) quit the program. [You should create a new "Project 6 " folder and copy your Project 5 files (HeartShapedBox.java, oject: HeartShapedBox List Menu App Page 2 of 11 HeartShapedBoxList,java, HeartShapedBox data_ 1.tot, and HeirtShapedBox data_0.txt) to it, rather than work in the same folder as Projeet 5 files.] - HeartShapedBox.java (assuming that vou suceesvfully created this class in the previous project, just copy the file to vour new projeet folder and so on to HeartShapedBoxL.ist.java on pase 4. Otherwise, you will need to create HeartshapedBox. lava as part of this proicet.) Requirements: Create a HeartShapedBox class that stores the label, radius, and beight. The HeartShapedBox class also includes methods to set and get each of these fields, as well as methods to ealculate the area of the heart shape, lateral surface ares, total surface area, and volume of a HeartShapedBox object, and a method to provide a String value of a HeartShapedBox object (i.e, a class instance). Design: The HeartShapedBox class has ficlds, a constructor, and methods as outlined below. (1) Fields (instance variables): label of type String, radius of type double, and height of type double. Initialize the String to " " and the doubles to zero in their respective declarations. These instance variables should be privale so that they are not directly accessibie from outside of the HeartShapedBox class, and theses should be the only instance variables in the class. (2) Constructor: Your HeartShapedBox class must contain a public constructor that aceepts three parameters (see types of above) representing the label, radius, and height. Instead of assigning the parameters directly to the fields, the respective set method for each field (described below) should be called. For example, instead of the statement label = labelln; use the statement setLabel(labelin); Below are examples of how the constructor could be used to create HeartShapedBox objects. Note that although String and numeric literals are used for the actual parameters (or argaments) in these examples, variables of the required type could have been used instead of the literals. Heartshapediox ex1 = nev HeartshapedBox ( min 1=,4,0,1,5), Heart.5hapedBox ex2 = new aeart5hapedBax I mi 2,10,0,2,4). BeartshapedBox ex3 - nek seurtshapedibex ( In 3,15.5,4.5)1 (3) Methods: Usually a class provides methods to access and modify each of its instance variables (known as get and set methods) along with any other required methods. The methods for HeartShapedBox, which should each be public, are described below. See formulas in Code and Test below. o get Labe1: Aceepts no parameters and returns a String repecsenting the label field. - set tabe 1: Takes a String parameter and returns a boolean. If the string parameter is not null, then the label field is set to the "Irimmet" String and the method retums true. Otherwise, the method returns false, and the label field is not set. Page 2 of 11 get Raxdius; Aceepts no parameters and retums a double representing the radius field. - setRadius: Accepts a double parameter and refums a boolean as follows. If the parameter is greater than zero, sets the radius field to the double passed in and returms true. Otherwise, the method returns false, and the ndius field is not set. getHeight: Accepts no parameters and returns a double representing the height field. setHoight: Accepts a double parameter and retums a boolean as follows. If the parameter is greater than zero, sets the height field to the double passed in and refurns true. Otherwise, the method returns false, and the height field is not set. heareShapedArea: Aceepts no parameters and retums the double value for the area of the beart shape calculated using the formula above. - LateralsurfaceArea: Accepts no parameters and returns the double value for the surface area calculated using the formula above. totalsurfaceArea: Accepts no paramcters and returns the double value for the total surface area calculated using the formula above- - volume: Accepts no parameters and returns the double value for the volume calculated using the using the formula above. tostring: Returns a String containing the informution about the HearShapedBox object formatted as shown below, incloding decimal formatting ( 7,1,10. (1) ") for the double values. Newline eseape sequences should be used to achieve the proper layout. In addition to the field values (or corresponding "get" methods), the following methods should be used to compute appropriate values in the toString method: heartShapedArea0. lateralSurface Area0, totalSurfaceArea 0 , and volume0. Each line should have no leading. and no trailing spaces (e.g. there should be no spaces before a newline ( (n) character). The results of printing the toString value of ex1, ex2, and ex3 respectively are shown below. HeartshapedBox "Ex 1 " with radius 4.0 unita and height 1.5 units: heart ahaped area =114.265 square unita lateral surface area =61.699 aguare vilts total surface area =290.23 square units: volume =171+398 cubie units HeartshapedBox "Ex 2 " with radius 10.0 units and height 2.4 unita: beart shaped area =714.159 square unita lateral aurface area =246.796 square unita total surface area =1,675.115 square units volume 1,713.982 eubic unite Heartshapediox "Ex 3m weh radtus 15.5 unite and height 4.5 untita: heart shaped area =1,715.768 square units lateral surface area =717.252 square units: total surtace area =4,148,787 square unita volume 7,720.954 cubic units Code and Test: As you implement your HeartShapedilox class, you should compile it and then test it using interactions. For cxample, as soon you have implemented and successfully compiled the constructor, you should create instances of HeartShapedBox in interactions (e.g., copyipaste the examples above on page 2). Remember that when you have an instance on the workbench, you can unfold it to see its values. You can also open a viewer canvas window and drag the instance from the Workbench tab to the canvas window. After you have implemented and compiled one or more methods, create an HeartShapedBox object in interactions and invoke each of your methods on the object to make sure the methods are working as intended. You may find it useful to create a separate class with a main method that creates an instance of fieartShapedBox then prints it out. This would be similar to the HeartshapedBok.App class you created in the previous project, except that in the HeartShapedBoxApp class you read in the values and then create and print the object. - HeartShapedBoxlist.java - cxiended from the previocs project by adding the last six methods below. (Assumine that vou successfully created this class in the previous project. just copy HeartShapedBoxList. dava to vour new Proiect folder and then add the indieated methods. Otherwise. you will need to create all of HeartshapedBoxl. ist lava as part of this preiect.) Requirements: Create an HeartShapedBoxl ist class that stores the name of the hist and an ArrayList of HeariShapedBox objects. It also includes methods that retum the name of the list, number of HeartShapedBox objects in the HeartShapedBoxl.ist, grand total surface area, total volume, average total surface area, and average volume for all HeartshapedBox objects in the HeartShapedBoxList. The toString method returns a String containing the name of the list followed by each HeartShapedBex in the ArrayL ist, and a suminary Info method returns summary information about the list (see below). Desigg: The HeartShapedBoxl ist class has two ficlds, a constructor, and methods as outlined below, (1) Flelds (or instance variables): (1) a String representing the name of the list and (2) an ArrayList of HeartShapedBox objects. These are the only fields (or instance variables) that this class should have, and both should be private. (2) Constructor: Your HeartShapedBoxlist class must contain a constructor that accepts a parameter of type String representing the name of the list and a parameter of type ArrayList clieartShapedBox representing the list of HeartShapedBlox objects. These parameters should be used to assign the fields described above (i.e, the instance variables). (3) Methods: The methods for HeartShapedBoxL ist are described below. getName: Returns a String representing the name of the list. numberorHeartshapedBoxes: Retums an int representing the number of HeartShapedBox objects in the HeartShapedBoxL ist. If there are zero HeartShapedBox objects in the list, zero should be retumed. - grandTotalSurfaceAreat Rctums a double represcating the sum of the individual total surface areas for all HeartShapedBox objects in the list. If there are nero HeartShapedBox objects in the list, zero should be retumed. Page 4 of 11 HeartShapedBox List Menu App Page 5 of 11 totaIVolume; Retums a double representing the total volume for all HeartShapedBox objects in the list. If there are zero HearshapedBox objects in the list, zero should be retured. averageTota1surfaceArea: Returns a double reptesenting the average total surface area for all HearshapedBox objects in the list. If there are zero HeartShapedBox objects in the list, zero should be returned. ave ragevolume: Returns a double representing the average volume for all HeartShapedBox objects in the list. If there are zero HeartShapedBox objects in the list, zero sbould be retumed. tostring: Returns a String (does not begin with in) containing the name of the list followed by each HeartShapedBox in the Arraylist. In the process of creating the return result, this toStringe method should include a while loop that calls the toString0 method for each HearthhapedBox object in the list (adding a in before and after each). Be sure to include appropriate newline escape sequences. For an example, see lines 3 through 22 in the output in the previous project from Heartihhpedioxl istApp for the the summary items in lines 24 through 30 of Example 1. These lines represent the return yaluc of the summaryinfo metbod below.] sunmary Info: Retums a String (does nos begin with 'i) containing the name of the list (which can change depending on the value read from the file) followed by various summary items: number of HeartShapedBox objects, total surface area, total volume, average surface area, and average volume. Use 4,410.08 - as the pattern to format the double values. In Example 1, see lines 24 through 30 in the output in the previous project from HeartShapedBoxListApp for the HeurtShapedBer_data_L. Lrt input file. Example 2 shows the output from HeanshapedBoxL istApp for the HearishapedBas_data_a.trf inpat file which contains a list name but no HeartShapedBox data The following six methods are new in this Project: - getList: Returns the ArrayList of HeartShapodBox objects (the second field above). readfi le: Takes a String parameter repesenting the file name, reads in the file, storing the list name and creating an ArrayList of HeartshapedBox objects, uses the list name and the Arraylist to create a HeartShapedBoxl ist object, and then returns the HeartShapedBoxList object. See note \#l under Important Considerations for the HeartShapedBoxListMenuApp class (last page) to see how this method should be called. The readF ile method header should include the throws FileNotYoundException clause. addHeartshapedBox: Returns nothing but takes three parameters (label, radius, and height), ereates a new HeartShapedBox object, and adds it to the HeartShapedBexList object. f indHeartshapedBox: Takes a label of a HeartShapedBox as the String parameter and returns the corresponding HeartShapedBox object if found in the HeartShapedBoxL List object; otherwise returns null. This method should jenone case when attempting to match the label. deletelleart ShapedBox: Takes a String as a purameter that represents the label of the HeartShapedBox and returms the HeartShapedBox if it is found in the HeartShapedBoxList object and deleted; otherwise retams null. This method should use Page 5 of 11 Page 6 of 11 the String equalslgnoreCase mathod when attempting to match a label in the HeartShapedBox object to delete. edi theartshapedBox: Takes three parameters (label, radias, and height), uses the label to find the corresponding the HeartShapedbox object. If found, sets the radius and height to the values passed in as parameters, and retums true. If not found, simply returns false. Note that this method should not set the label. Code and Test: Remember to import java.util AmayList, java util Scanner, java io. File, java.io.FileNotFoundException. These classes will be needed in the readFile method which will require a throws clause for FileNotFoundException. Some of the methods above require that you use a loop to go through the objects in the ArrayList. You may want to implement the class below in parallel with this one to facilitate testing. That is, after implementing one to the methods above, you can implement the corresponding "case" in the switch for the menu described below in the HeartShapedBoxListMenuApp class. - HeartShapedBoxlistMenuApp.java (replaces HeartShapedBoxl istApp class from the previous project) Requirements: Create a HeartShapedBoxL istMenuApp class with a main method that presents the user with a menu with eight options, each of which is implemented to do the following: (1) read the input file and create a HeartShapedBoxList object, (2) print the HeartShapedBoxList object, (3) print the summary for the HeartShapedBoxList object, (4) add a HeartShapedBox object to the HeartShapedBoxList object, (5) delete a HeartShapedBox object from the HeartShapedBoxList object, (6) find a HeartShapedBox object in the HeartShapedBoxL ist object, (7) Edit a HeartShapedBox object in the HeartShapedBoxlist object, and (8) quit the program. Design: The main method should print a list of options with the action code and a short description followed by a line with just the action codes prompting the user to select an action. After the user enters an action code, the action is performed, including output if any. Then the line with just the action codes prompting the user to select an action is printed again to accept the next code. The first action a user would normally perform is ' R ' to read in the file and create a HeartShapedBoxList object. However, the other action codes should woek even if an input file has not been processed. The user may continue to perform actions until ' Q is entered to quit (or end) the program. Note that your program should acecpt both upgerease and lowercase action codes (sec items 3 and 4 in the Code and Test section below). Example I (next page) shows the output produced by running HeartShapedBoxL istMenuApp and printing the action codes with short descriptions followed by the prompt with the abbreviated action codes waiting for the user to select from the menu. Project: HeartShapedBox List Menu App Page 7 of 11 Below shows the output after the user entered ' r ' and then (when prompted) entered the file name. Notice the output from this action was "File read in and HeartshapedBox List created". This is followed by the prompt with the action codes waiting for the user to make the next selection. You should use the Hear_happedBox_data_l. .tut file from Project 5 to test your program. Example 2 The result of the user selecting ' p ' to Print HeartShapedBox List is shown below and next page. Project: HeartShapedBox List Menu App Page 8 of 11 The result of the user selecting "s" to print the summary for the fist is shown below, Framnio 4 The result of the user selecting 'a' to add a HeartShapodBox object is shown below. Note that after 'a' was entered, the user was prompted for label, radius, and height. Then after the HeartShapedBox object is added to the HeartShapedBox List, the mesage "** HeartShapedBox added ***" was printed. This is followed by the procnpt for the next action. After you do an "add", you should do a "print" or a "find" to confirm that the "add" was successful. Fxamnle 5 Here is an example of the successful "delete" for a HeartShapedBox object, followed by an attempt that was not successful (i.e, the HearShapedBox object was not found). Do "p" to confirm the "delete". roject: HeartShapedBox List Menu App Page 9 of 11 In the example below, there is a successful "find" for a HeartshapedBox object with label ex 3 (with case ignored), followed by an attempted "find" for Ex 99 that was not successful (i.e., the HeartShapedBox object with label Ex 99 was not found). Example 7 Below is an example of the successful "edit" for a HeartShapedBox object, followed by an attempt that was not successful. To verify the edit, you should do a "find" for "ex 1" or you could do a "print" to see the whole list. Note the actual label. Ex. la is shown en line 5 rather than ex I which wis enterod by the user. Edit does net medify the label. Example 8 Entering a ' q ' should quit the application with no message. Examble 9 Finally, if a code other than the ones in the "Enter Code" list is entered, the code is considered invalid and an appropriate message is priated, then the user is asked to enter a code again as shown below. Example 10 Code and Test: This class should import java util.Scanner, java.util ArrayList, and java,io.FileNotFoundException. Carefully consider the following important considerations as you develop this class. 1. At the beginning of your main method, you should declare and create an Array List of HeartShapedBox objects and then declare and create a HeartShypedBoxL ist objeet using the list name and the ArrayList as the parameters in the constructor. This will be a HeartShapedBoxList object that contains no HeartShipedBox objects. For example: string . ** no liet nane assigned **? Arrayilst CHeartshaped mox - nev ArewyListefeartshapedBox 0 i Heartchapedioxtist - new Meartshapedbeatist It The ' R ' option in the mena should invoke the readFile method on your HeartShapedBoxL ist object. This will return a new HeartShapedBoxl, ist object based on the data read from the file, and this new HeartShapedBexlist object should replace (be assigned to) your original HeartShapedBoxList object variable in main. Since the readFile method throws FileNotFoundException, your main method noeds to do this as well. 2. Very Important You should declare only one Scanner on System in for vaur entire program, and this should be done in the main method. That is, all input from the keyboard (System.in) must be done in your main method. Declaring more than one Scanner on System. in in your program will likely result in a vary low seore from Web-CAT. 3. After you read in the code as a String, you should invoke the toUpperCase0 method on the code and then convert the first character of the String to a char as shown in the two statements below. code-code.toupperCase(17charcodeChar-code,charat(0); 4. For the menu, your switch statement expression should evaluate to a char and each case should be a char. After printing the ment of actions with descriptions, you should have a do-while loop that prints the prompt with just the action codes followed by a switch statement that performs the indicated action. The do-while loop ends when the user enters ' q ' to quit. You should strongly consider using a for-each loop as appropriate in the new methods that require you to search the list. You roject: HeartShapedBox List Menu App Page 11 of 11 should be able to test your program by exercising each of the action codes. After you implement the "Print HeartShapedBox List" option, you should be able to print the HeartShapedBox List object after operations such as ' A ' and ' D ' to see if they wotked. You may also want to run in debug mode with a breakpoint set at the switch statement so that you can step-into your methods if something is not working. In conjunction with running the debugger, you should also create a canvas drag the items of interest (e.g, the Scanner on the file, your HeartShapedBoxL ist object, ete.) onto the canvas and save it. As you play or step through your program, you'll be able to see the state of these objects change when the ' R ', "A', and ' D options are selected. Although your program may not use all the methods in your HeartShapedBox and HeartShapedBoxL ist classes, you should ensure that all your methods work according to the specification. You can run your program in the carvas and then after the file has been read in, you can call methods on the HeartShapedBoxList object in interactions, or you can write another class and main method to exercise the methods. Web-CAT will test all methods to determine your project gradeStep 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