Explain the purpose of the code and identify which part of the TMA question you are answering in each case.

Words: 1794
Pages: 7
Subject: Uncategorized

“This question explores exception handling, error recovery and avoidance as well as file-based input and output. You should be able to answer this question once you have completed Chapter 14.There is no provided project for this question and there is no online test facility.The scenario will be one you choose yourself, in consultation with your tutor, and following the guidelines we provide below.You must agree your proposed scenario with your tutor before you develop your solution, and this discussion should take place well in advance of the cut-off date for M250 TMA 03. Marks are awarded for this discussion. See part (a) below.You can receive full marks in this question if you discuss your scenario with your tutor, give a clear description of your scenario, successfully implement all features specified in the guidelines, and test your code following the instructions given.For your own interest you may choose to include extra features that go beyond those specified in the guidelines, but this will not gain additional marks, so we suggest that you concentrate first on meeting the basic specification and only extend it if you are confident and have the time. Your tutor may not give feedback on such additional features, especially if they are complex.ScenarioYou should choose a scenario that interests you for an organisation that needs to keep details of its members (which may be very broadly interpreted as things owned by the organisation in some sense, e.g., persons, animals, players etc.) in a CSV file.You will need to write two Java classes:A class representing a member of the organisation.This class should have no more than four instance variables.A class holding the membership database of the organisation as a TreeSet.Classes may include one or more constants if these are appropriate for your scenario.Your project should make use of code from Chapter 14 to demonstrate your understanding of exception handling, reader and writer classes and the Scanner class.If your project doesn’t work then you should submit what you have done along with an explanation for your tutor as to what problems you encountered and how you went about trying to fix them.The scenario below is an example of how you might interpret the requirements for this question.You may not use the example scenario below or any examples in the module materials in your solution. The scenario must be your own idea.Example ScenarioRequirement AnswerGeneral scenario Description and backgroundMy organisation is an art gallery that maintains a CSV file of all artists (members) whose work it currently sells.Artists have the following attributes:name (they sign their work with)medium (technique they use e.g., oil)style (e.g., pointillist)famous (which may be true or false).These attributes are stored in a file as comma-separated values, with one artist per row of the CSV file.The scenario is modelled in Java by the classes Artist (members) and Gallery (organisation):Class representing a member Name ArtistDescription and types of instance variables Artist has four instance variables:name, medium and style of type Stringfamous of type booleanA four-argument constructor, getter and setter methods are provided as well as equals, hashCode and toString. The Artist class implements the Comparable interface and artists will be sorted on the name field. (We assume that artist names are unique.)Class holding the membership database Name GalleryDescription and type of instance variable holding data Gallery holds a TreeSet of Artist, called artists, and provides methods to read from a CSV file to the artists set, and write from the artists set to a CSV file.Additionally, Gallery provides methods to update attributes for a particular artist, add an artist, remove an artist, clear the artists set, produce a new collection of artists based on a filter of style and can print the artists in sort order by artist name.Note that although you will choose the names of the classes in your scenario, and you will be customising the functionality of your methods to your chosen scenario, the methods you provide must have the same names and purposes as in the list in part (c) of this question.a.Describe your scenario briefly for your tutor using the format suggested by the example above. You can copy a blank table from the file TMA03Q3ScenarioDiscussion.docx in the TMA03Download folder. Once the scenario is agreed with your tutor, paste your completed table into your Solution Document.(5 marks)Now Launch BlueJ and create a new project TMA03_Q3_SolXX in the TMA03Download folder, where XX should be replaced by your own initials.b.In this part you will work on the class that represents the members of your organisationi.Add a class to your project to represent the members of your organisation. It should have no more than four instance fields, plus setter and getter methods as appropriate, and a constructor to initialise the fields. (You may also use constants.)ii.Add toString and other methods as appropriate for your class to maintain whatever sort order is required and determine equality.Don’t forget that the Java language requires you to implement the related methods equals, hashCode and compareTo for use of your member class in Java collections, and that these methods should be consistent with each other.(5 marks)c.In this part you will add a class to represent your organisation.i.Add a second class to your project to represent your chosen organisation. It should have an instance field for a suitable collection of members and a constructor to initialise the collection to an empty collection, as well as a clear method to delete all entries from the collection. (The clear method does not affect the CSV file you will create.)(5 marks)ii.Add a method populate that takes no arguments and which creates five different example member objects and adds these to your members collection. The method should not use any user input.(5 marks)iii.Add a method writeCSVFile that takes an argument representing the name of the file to be created. It should write the members collection (which we assume has been populated already) to the file whose name is passed as an argument. The CSV file does not have a header line with the names of the columns.Your method should use appropriate exception handling.Remember that in a CSV file comma-separated values must not have added spaces between them.Use your method to set up an initial test CSV file in your project folder called members.csv. The file should contain details of five members.(5 marks)iv.Add a method readCSVFile that takes an argument representing the name of the members file to be read from your project folder.The method should create a new member object for each line read from the members CSV file, with each member object correctly initialised according to the comma-separated values in the current row of the members.csv file.If you were unable to complete the writeCSVFile method, you can create a CSV file using a text editor. Remember that the comma-separated values must not have added spaces between them. Include a note to your tutor in your Solution Document if you did this.Starting with an empty collection, the readCSVFile method should add each member object to your organisation’s member collection.Your method should use appropriate exception handling and should make use of at least one Scanner.(10 marks)d.Add the following methods to your organisation class, ensuring these are named exactly as in the table below:method name Brief description parameter(s) needed?addMember Adds a member to the members collection if it is not already present. Otherwise prints an error message including some identification of which member could not be added. yesremoveMember Removes a member from the members collection. Returns true or false depending on whether this is successful or not. yesupdateMember Updates a single attribute of your choice for a particular member. This should not be an attribute relied on in determining equality. You may assume the member is in the members collection. yesselectMembers Returns a collection of members using the supplied argument as a filter. E.g., it may select all members having a particular attribute matching the argument, or with an attribute larger than the argument. yesprintMembers Using a loop, prints the whole collection of members, one member per line of output, and finally prints a blank line. (This should not rely on the toString method of the organisation’s member collection.) no(25 marks)e.Now test your codeOpen the Terminal window and in the Code Pad, create an instance of your organisation class then write some code to:call populate to create and add five test members to your collectioncall writeCSVFile to write the members collection to file members.csvcall readCSVFile to read members.csvcall printMembers to display the members collectioncreate a new member and add this to the members collectionremove a different member from the members collectionupdate a member in the collectioncall printMembers again to display the members collectioncall selectMembers using a filter of your choice, assigning the resulting collection to a suitable variable. Use a println statement to print out the contents of the collection, using the collection’s built-in toString method.Copy your test code and the Terminal output from your testing into your Solution Document.Finally, paste the contents of the members.csv file into your Solution Document.(5 marks)f.Go back and check that you have provided Javadoc comments for your classes, constructors and methods, including the @author, @version, @param and @return annotations where appropriate. Be sure that your comments explain the purpose of the code and identify which part of the TMA question you are answering in each case.Also check that you have used a consistent style across the classes.See the M250 Code Conventions document for more advice on coding style.(5 marks)When you are done testing your code, don’t forget to:paste the whole completed classes into your Solution Document as text, using a monospaced font.Include a message to your tutor as to what you did to try and resolve problems if you were unable to get your code to work.Go back now and check that you have done this!”Hi I have also attached the scenario to use.

Let Us write for you! We offer custom paper writing services Order Now.

REVIEWS


Criminology Order #: 564575

“ This is exactly what I needed . Thank you so much.”

Joanna David.


Communications and Media Order #: 564566
"Great job, completed quicker than expected. Thank you very much!"

Peggy Smith.

Art Order #: 563708
Thanks a million to the great team.

Harrison James.


"Very efficient definitely recommend this site for help getting your assignments to help"

Hannah Seven