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...

1 answer below »
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
Answered Same DayJul 06, 2021

Answer To: Assignment 2 Version Number: 1.10 (July 5th, 2020) Assignment 2 Land Registry, Part 2 To be...

Valupadasu answered on Jul 08 2021
137 Votes
CST8284_20S_Assignment2/.classpath

    
    
    
CST8284_20S_Assignment2/.project

     CST8284_20S_Assignment2
    
    
    
    
        
             org.eclipse.jdt.core.javabuilder
            
            
        
    
    
         org.eclipse.jdt.core.javanature
    
CST8284_20S_Assignment2/.settings/org.eclipse.jdt.core.prefs
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclip
se.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
CST8284_20S_Assignment2/bin/cst8284/asgmt1/landRegistry/Property.class
package cst8284.asgmt1.landRegistry;
public synchronized class Property implements java.io.Serializable {
private static final double TAX_RATE_PER_M2 = 12.5;
private static final int DEFAULT_REGNUM = 999;
private int xLeft;
private int yTop;
private int xLength;
private int yWidth;
private int regNum;
private int area;
private double taxes;
public static final long serialVersionUID = 1;
public void Property();
public void Property(int, int, int, int);
public void Property(Property, int);
public void Property(int, int, int, int, int);
public int getXLeft();
public void setXLeft(int);
public int getXRight();
public int getYTop();
public void setYTop(int);
public int getYBottom();
public int getYWidth();
public void setYWidth(int);
public int getXLength();
public void setXLength(int);
public int getRegNum();
private void setRegNum(int);
public int getArea();
public double getTaxes();
public String toString();
public boolean equals(Object);
public boolean hasSameSides(Property);
public boolean overlaps(Property);
}
CST8284_20S_Assignment2/bin/cst8284/asgmt1/landRegistry/RegControl.class
package cst8284.asgmt1.landRegistry;
public synchronized class RegControl {
private java.util.ArrayList registrants;
private java.util.ArrayList properties;
public void RegControl();
public java.util.ArrayList getRegistrants();
public java.util.ArrayList getProperties();
public Registrant addNewRegistrant(Registrant);
public Registrant findRegistrant(int);
public java.util.ArrayList listOfRegistrants();
public Registrant deleteRegistrant(int);
public Property addNewProperty(Property);
public boolean deleteProperties(java.util.ArrayList);
public Property changePropertyRegistrant(Property, int);
public java.util.ArrayList listOfProperties(int);
public java.util.ArrayList listOfAllProperties();
private Property propertyOverlaps(Property);
public boolean saveToFile(java.util.ArrayList, String);
public java.util.ArrayList loadFromFile(String);
}
CST8284_20S_Assignment2/bin/cst8284/asgmt1/landRegistry/Registrant.class
package cst8284.asgmt1.landRegistry;
public synchronized class Registrant implements java.io.Serializable {
private static int REGNUM_START;
private static int currentRegNum;
private int REGNUM;
private String firstName;
private String lastName;
public static final long serialVersionUID = 1;
static void ();
public void Registrant();
public void Registrant(String);
public int getRegNum();
private static void incrToNextRegNum();
public String getFirstName();
public void setFirstName(String);
public String getLastName();
public void setLastName(String);
public boolean equals(Object);
public String toString();
}
CST8284_20S_Assignment2/bin/cst8284/asgmt1/landRegistry/RegLauncher.class
package cst8284.asgmt1.landRegistry;
public synchronized class RegLauncher {
public void RegLauncher();
public static void main(String[]);
}
CST8284_20S_Assignment2/bin/cst8284/asgmt1/landRegistry/RegView.class
package cst8284.asgmt1.landRegistry;
public synchronized class RegView {
private static java.util.Scanner scan;
private static RegControl rc;
private static final int ADD_NEW_REGISTRANT = 1;
private static final int FIND_REGISTRANT = 2;
private static final int LIST_REGISTRANTS = 3;
private static final int DELETE_REGISTRANT = 4;
private static final int ADD_NEW_PROPERTY = 5;
private static final int DELETE_PROPERTY = 6;
private static final int CHANGE_PROPERTY_REGISTRANT = 7;
private static final int LIST_PROPERTY_BY_REGNUM = 8;
private static final int LIST_ALL_PROPERTIES = 9;
private static final int LOAD_LAND_REGISTRY_FROM_BACKUP = 10;
private static final int SAVE_LAND_REGISTRY_TO_BACKUP = 11;
private static final int EXIT = 0;
private static final String PROPERTIES_FILE = LandRegistry.prop;
private static final String REGISTRANTS_FILE = LandRegistry.reg;
static void ();
public void RegView();
private RegControl getRegControl();
public static void launch();
private static int displayMenu();
private static void executeMenuItem(int);
private static String getResponseTo(String);
private static int requestRegNum();
private static Property makeNewPropertyFromUserInput();
private static Registrant makeNewRegistrantFromUserInput();
public static void viewAddNewRegistrant();
public static void viewFindRegistrant();
public static void viewListOfRegistrants();
public static void viewDeleteRegistrant();
public static void viewAddNewProperty();
public static void viewDeleteProperty();
public static void viewChangePropertyRegistrant();
public static void viewListPropertyByRegNum();
public static void viewListAllProperties();
public static void viewLoadLandRegistryFromBackUp();
public static void loadLandRegistryFromBackUp();
public static void...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here