Hello, i am looking for someone to help with my assignment 2
Assignment 2 Version Number: 1.10 (July 5th, 2020) Assignment 2 Land Registry, Part 2 To be submitted online not later than Saturday, July 11th, 2020, 11:59 p.m. Description: In this lab you’ll continue to add new features to the land registry. Along the way, you’ll demonstrate your understanding of the following course learning requirements (CLRs), as stated in the CST8284—Object Oriented Programming (Java) course outline: 1. Write java programming code to solve a problem, based on the problem context, including UML diagrams, using object-oriented techniques (CLR II) 2. Use basic data structures (CLR III), including implementing arrays of primitive and reference types 3. Implement inheritance and polymorphism (CLR IV) 4. Use ArrayLists to manage objects (CLR V) 5. Implement program Input/Output operations by storing objects to a file using serialization (CLR VII) 6. Produce code that has been tested and executes reliably (CLR VIII) 7. Debug program problems using manual methods and computerized tools in an appropriate manner. (CLR X) 8. Identify appropriate strategies for solving a problem (CLR XI) Worth 4.0% of your total mark Assignment 2 Page 1 Assignment 2 Land Registry, Part 2 Program Description In this assignment you’ll add additional features to the Land Registry you started in Assignment 1. For those students who failed to submit that assignment, or for those whose submission was partially defective, you may use my copy of Assignment 1, posted on Brightspace, as starter code for your Assignment 2 submission. (Even if you’re satisfied with your Assignment 1 code, you might want to look over the sample code anyway, to see how you might have implemented things differently.) Whatever your reasons, you may use the Assignment 1 code in whole or in part, with a proper citation, in building your Assignment 2. I. Load the Assignment2 project and copy your existing classes to the new Project a) In Eclipse, open a new project called CST8284_20S_Assignment2 and copy the five classes from Assignment 1 to it. Refactor each class’s package statement as necessary. b) The UML diagram for this assignment has been modified to reflect the changes in Assignment 2. This may affect some of the declarations for methods you created in Assignment 1, which will need to be refactored for this assignment. So check the new UML carefully for changes in the declarations, access modifiers, use of static, etc. In particular note that setRegNum() in RegControl is private, to prevent illegal registrations. (This was an oversight in the Assignment 1 document.) c) Before making the additions specified in Section II, note that the same rules apply to this assignment as the last, briefly stated as: 1. Follow the UML diagram exactly as it is written, according to the most up-to-date version of this document. You cannot add members that are not written in the UML diagram, nor can you neglect any of them either. 2. Most of the new methods indicated in the UML diagram are intended to be used (again, with the exception of some getters and setters). Take the UML as your guide not just of what needs to be written, but of how the pieces are connected to one another. 3. Employ best practices at all times, especially code reuse. And to reiterate a point made in Assignment 1: RegControl never uses print() or Scanner for user IO; that task is left exclusively to RegView. II. Add the following new features to your Land Registry application a) Replace every array with an ArrayList Remove the registrants and properties arrays and replace them with ArrayLists of type Registrant and Property respectively. Then change all the code that used these arrays in Assignment 1 and replace it with appropriate ArrayList methods instead. In particular, remove lastRegistrantIndex and lastPropertyIndex along with their getters; the last used index is readily available from ArrayList’s size() method, hence we don’t need to keep track of this location anymore. (Note that you still need to use getters to access the ArrayLists.) Also, since ArrayLists are automatically resizable, there’s no need to check to see if we’ve reached the end of the array; you can remove that code as well. Similarly, there’s no longer any need to check if RegControls methods have returned null to indicate when an array’s size has been exceeded; this is no longer a possibility, and so that code can be removed as well. Other methods will have their contents drastically modified. Assignment 2 Page 2 b) Add File IO to the existing code Using the hybrid lectures and notes as your guide, add file I/O functionality to your application. You’ll need to create two new methods in RegView, one to save the two ArrayLists to files, the other to retrieve this information. Details are provided below. saveToFile() This method is used to save the contents of either of the two ArrayLists to a file stored on the hard drive. As indicated in the UML diagram, this method takes two parameters: an ArrayList of type T (where T is either a Registrant or a Property) and the name of the file to be saved to. Name the two files LandRegistry.reg and LandRegistry.prop respectively. DO NOT hardcode the file location to a particular subdirectory, as your code may not work correctly when it is transferred to another platform. Also, do not prompt the user for a filename; the two file names are encoded as constants to be used internally by your program, as indicated in the UML (in RegView). By default, cst8284.asgmt1.landRegistry +main(args: String[]): void RegLauncher +RegView() -getRegControl(): RegControl // Same as asgmt 1 +launch(): void -displayMenu(): int -executeMenuItem(choice: int): void -getResponseTo(s: String): String -requestRegNum(): int -makeNewPropertyFromUserInput(): Property -makeNewRegistrantFromUserInput(): Registrant +viewAddNewRegistrant(): void +viewFindRegistrant(): void +viewListOfRegistants(): void +viewDeleteRegistrant(): void +viewAddNewProperty(): void +viewDeleteProperty(): void +viewChangePropertyRegistrant(): void +viewListPropertyByRegNum(): void +viewListAllProperties(): void +viewLoadLandRegistryFromBackUp(): void +viewSaveLandRegistryToBackUp: void -scan: Scanner -rc: RegControl // Same as asgmt 1 -PROPERTIES_FILE: String = "LandRegistry.prop" -REGISTRANTS_FILE: String = "LandRegistry.reg" -ADD_NEW_REGISTRANT: int = 1 -FIND_REGISTRANT: int = 2 -LIST_REGISTRANTS: int = 3 -DELETE_REGISTRANT: int = 4 -ADD_NEW_PROPERTY: int = 5 -DELETE_PROPERTY: int = 6 -CHANGE_PROPERTY_REGISTRANT: int = 7 -LIST_PROPERTY_BY_REGNUM: int = 8 -LIST_ALL_PROPERTIES: int = 9 -LOAD_LAND_REGISTRY_FROM_BACKUP: int = 10 -SAVE_LAND_REGISTRY_TO_BACKUP: int = 11 -EXIT: int = 0 RegView // Unchanged from Assignment 1 Registrant -registrants: Arraylist
-properties: ArrayList +RegControl() -getRegistrants(): ArrayList -getProperties(): ArrayList +addNewRegistrant(reg: Registrant): Registrant +findRegistrant(regNum: int): Registrant +listOfRegistrants(): ArrayList +deleteRegistrant(regNum: int): Registrant +addNewProperty(prop: Property): Property +deleteProperties(ArrayList): boolean +changePropertyRegistrant(originalProperty: Property, newRegNum: int): Property +listOfProperties(regNum: int): ArrayList +listOfAllProperties(): ArrayList -propertyOverlaps(prop:Property): Property +saveToFile(source: ArrayList, fileName: String): boolean +loadFromFile(fileName: String): ArrayList RegControl // Unchanged from Assignment 1 // except for setRegNum, which is private Property Assignment 2 Page 3 your files will be saved into the default directory associated with your project (typically the src folder for the project, or one of its subdirectories). Note that before saving the current contents of an ArrayList to one of the these files, your program should check to see if a previous copy of the file already exists in the default directory. If it does, delete it first before saving the most recent copy of the ArrayList. Java should overwrite the existing file automatically, but in some languages the default behaviour is to append the new objects onto the existing file, creating potential duplicate entries. To be safe, use the File methods covered in the hybrids on File IO to check for the existence of the file first, then delete any existing copies of files before saving a the ArrayList to a fresh file. loadFromFile() This method performs the opposite operation, loading the file contents into an ArrayList of type T. As indicated in the hybrid videos, you should use EOFException to terminate loading of the ArrayList from the file. Just as you need to be careful to update the file with fresh contents when you load it from an ArrayList, so also you should save the contents of the file to an empty ArrayList, rather than add the file objects to an existing ArrayList. Students often initially encounter problems loading and saving file contents. The most common cause is that the file you think you are loading from/to does not actually exist in the folder you think you are accessing. Check carefully (using debug, of course, along with Windows Explorer) to ensure that there’s actually a file where you think it is; if it isn’t there, you’ll get a NullPointerException, or worse, when you attempt to load from a File object the contents of a physical file that doesn’t actually exist. Another problem: students frequently assume that because their program works fine with the file loaded on their laptop, it will work fine everywhere. But when your lab instructor runs your program, there’s no guarantee that the same file