Assignment 1
Assignment 1
Land Registry
To be submitted online not later than Monday, June 22nd, 2020, 11:59 p.m.
Description:
The purpose of this project is to build a land registry, that is, an application that allows
a user to register a piece of land of a requested size and location. This first assignment
focuses on a
ays of objects, chaining, overloading, and getters/setters. It will evolve
further as we add new features in Assignments 2, 3, and 4 as your understanding of Java
increases. In building this application, you will demonstrate your understanding of the
following course learning requirements (CLRs), as stated in the CST8284—Object
Oriented Programming (Java) course outline:
1. Install and use Eclipse IDE to debug your code (CLR 1)
2. Write java programming code to solve a problem, based on the problem
context, including UML diagrams, using object-oriented techniques (CLR II)
3. Use basic data structures (CLR III), including implementing a
ays of primitive
and reference types
4. Implement program Input/Output operations (CLR V)
5. Debug program problems using manual methods and computerized tools in an
appropriate manner. (CLR X)
6. Identify appropriate strategies for solving a problem (CLR XI)
Worth
7.5%
of your total
mark
Version Number:
1.13 (June 15, 2020)
Assignment 1
Page 1
Assignment 1
Land Registry
Program Description
This application allows the user to store and retrieve
property information loaded in a land registry. (A land
egistry allows a governments and organizations to
ecord and track land ownership.) It includes such
information as the dimensions and location of each
property, the ownership of the property (which
could be an individual or an organization), the stated
purpose of the property (which could be industrial,
agricultural, commercial, recreational …etc), and the
annual taxes to be paid.
In this early version of the program, our registry is
somewhat basic. However, it will grow in size and
functionality as we add new features to it in
Assignments 2, 3 and 4. To keep the coding simple, a
number of assumptions have been made:
1. Each property is rectangular in shape. That is,
it has a length and width. Additionally, each
property has a top and left position,
co
esponding to the coordinates of the top
left corner of the property;
2. A property cannot be registered (that is,
loaded into an a
ay of properties) unless it has
a registration number (or regNum for short).
Each registration number is tied to a Registrant
object, which is a registered person or
organization to whom a unique number is
assigned. Like the properties, each Registrant
object is stored in its own a
ay. (Both a
ay
sizes will be kept deliberately small, to help
with debugging.
3. For now, the size of these two a
ays is
limited—this helps with testing. We’ll increase
these sizes in a later assignment when we
eplace each a
ay with an A
ayList. For the
present, size your a
ays using the values
indicated in this document, as indicated below.
4. The total size of the space available for
property registration is 1000 m X 1000 m.
Since all measurements will be recorded in
metres, a valid property location and
dimension can be any value between 0 and
1000.
5. The minimum size of any allowed property has
dimensions 20 X 10, i.e. a length of 20 m and a
width of 10 m—big enough to fit a reasonably
large house. The coordinates of a new
property can be anywhere inside the 1000 m X
1000 m area available, provided it does not
overlap with an existing property already
egistered.
I. Create the Project, package and classes
a. In Eclipse, create a new project called
CST8284_20S_Assignment1. To this project
add a package called
cst8284.asgmt1.landRegistry. Then,
following the UML diagram below, add each of the
classes indicated to this package.
Note
The term ‘property’ has a number of different
meanings in English. In this document, a reference to
a property will usually mean an instance of the
Property class, that is, an abstract representation,
in code of a piece of land having such features as size,
location, and ownership. The term should not be
confused with the property of an object, which
means something totally different. For the most
part, the meaning of the term ‘property’ should be
clear from the context. To avoid confusion, we’ll
efer to an object’s properties when we’re talking
about the properties of an object in general; when
the word ‘property’ is used by itself, it means an
instance of the Property class, described below.
Note also, Java has its own Properties class (in the
java.utils.* package); be certain that Eclipse does not
attempt to import and use this class in place of your
Property class which you’ll create in the
cst8284.asgmt1.landRegistry package.
Assignment 1
Page 2
. Before you proceed to the details of each class in
Section II, note the following rules about this
assignment, which must be strictly adhered to:
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—and this
applies to features that don’t appear to have
any use in your code (at present; on this note,
e sure to read item (2) below). If it’s written
in the UML, it’s not optional: write the code you’re
directed to write, or marks will be deducted.
And if you want to get creative with the
equirements, you may. But do so on you own
time, and do not submit your ‘improved’ version
and expect to get marks for it. In short: if you
hand in code that differs in any way from the
UML, you will lose marks. Of course, how
you choose to implement each specific
method in the program is up to you. But the
way in which those pieces connect is directed
y the UML.
2. Aside from a few setters, all methods
indicated in the UML are intended to be put
to use in your code. So if there’s a method
that’s required in the UML and you’re not
using it, you’re likely missing something, and
your code is not being used co
ectly—and
you will lose marks. Take the UML as an
indication not just of what needs to be coded, but
of how the code is to be connected in a well-
written, optimized application (given the rather
limited requirements of this assignment).
So if you can’t figure out how certain features
(such as the private static final
constants declared in the RegView class) will
e used in code, think first, then ask if you’re
stuck: these things exist for a reason.
3. Employ best practices at all times: reuse code,
don’t copy and paste; don’t declare variables
unnecessarily; keep your code to the
minimum needed to ensure the program
functions reliably; only setters and getters talk
directly to private fields, everything else talks
to the public setters and getters; and chain all
overloaded constructors and methods.
Additional information on submission requirements
are included in Section III, ‘Notes, Suggestions, Tips,
and Warnings.’
II. Write the code indicated for each class
As seen in the UML diagram below, five classes are
used in this application: RegLauncher, RegView,
RegControl, Registrant, and Property.
Regarding the five classes you’ll be coding for: there’s
a few general ideas to keep in mind as you proceed
(specific details on each class follow below). Most of
what you need to know should be obvious from the
UML diagram, but the following four items may not
e readily apparent, and may only be infe
ed by
careful examination:
First: We’ll assume, for now, that the user of our
application is well-behaved and will not deliberately
e entering any bad data—an assumption we’ll
overturn in a later assignment, after the subject of
Exceptions has been introduced. But at this point,
there’s no need to check the validity of the data
(with the exception of the check to ensure that
two properties do not overlap—see below).
Second: remember that an object’s private
properties are never accessed directly; everything
goes through getters and setters. For example, the
statement:
getRegistrants[getRegistrantIndex()]
.getRegNum()
eturns the registration number of the last
egistrant in the a
ay of registrants. Whether you
understand everything in this statement or not
doesn’t matter at the point; what matters is that
the code never accesses a private property
directly: everything is done through the getters and
setters.
Third: Simply because a method returns an object
or a boolean value does not mean that value needs
to be used in the application. Typically, if a method
eturns an object, that object’s toString()
Assignment 1
Page 3
`
cst8284.asgmt1.landRegistry
+main(args: String[]): void
RegLauncher
+RegView()
-getRegControl(): RegControl
See June 15th
note
+launch(): void
-displayMenu(): int
-executeMenuItem(choice: int): void
-getResponseTo(s: String): String
-requestRegNum(): int
-makeNewPropertyFromUserInput(): Property
-makeNewRegistrantFromUserInput(): Registrant
+viewAddNewRegistrant(): void
+viewFindRegistrant(): void
+viewListOfRegistants(): void
+viewAddNewProperty(): void
+viewChangePropertyRegistrant(): void
+viewListPropertyByRegNum(): void
+viewListAllProperties(): void
-scan: Scanner
-rc: RegControl