sk 3: Properties (Assignment) You have to write a program for an estate agency. The program must manage renting of properties. Your solution must implement the concepts of encapsulation and inheritance. Information required on all the properties listed to be rented: Type of property (residential (R) or business (B)), name of the owner, contact number of owner, duration of the contract (in months). Residential: Type of property (Flat, Townhouse or House), number of bedrooms, number of bathrooms, number of garages, rent per month. Business: Size in square meters, insurance per month, rent per month. Two separate reports must be displayed for the two types of properties. The output for residential properties must be displayed as follows: Owner  Contact number   Months   Type   BedR BathR   Rent(pm)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Task 3: Properties (Assignment)
You have to write a program for an estate agency. The program must manage renting of properties. Your solution must implement the
concepts of encapsulation and inheritance.
Information required on all the properties listed to be rented: Type of property (residential (R) or business (B)), name of the owner, contact
number of owner, duration of the contract (in months).
Residential: Type of property (Flat, Townhouse or House), number of bedrooms, number of bathrooms, number of garages, rent per month.
Business: Size in square meters, insurance per month, rent per month.
Two separate reports must be displayed for the two types of properties. The output for residential properties must be displayed as follows:
Owner  Contact number   Months   Type   BedR BathR   Rent(pm)
Joe Bloom   0879678223   24   T   4   3   R19000
The rent for residential properties depend on the type of property and the number of bedrooms.
Flat – R8000pm + R 500pm per bedroom
Townhouse – R 15000pm + R 1000pm per bedroom
House – R 12000pm + R800pm per bedroom
The output for business properties must be displayed as follows:
Owner   Contact number   Months   Size Insurance(pm)   Rent(pm)
Sue Smith   0723456872   12   280   R7000.00   R70000.00
The rent for business properties is calculated based on the size of the property. The rent per square meter is R250.00

1. Write the superclass
Write a superclass Property.
a) Identify the common properties for a property and declare them
as private instance fields.
b) Constructors:
No arguments constructor (also called the default constructor)
Parameterized constructor.

c) Methods:
- Accessor methods (getters) for the instance fields.
- A toString() method to return a string that will neatly display
all the information to describes the object. Example:
Joe Bloom  0879678223  2


2. Write a subclass called ResProperty that inherits from the Property superclass
a) Declare local instance field(s).
b) Two constructors:
No arguments constructor
Parameterized constructor:
- Remember: Call the constructor of the super class using the super keyword.
c) Methods:
-Accessor method for the instance field
-calcMonthRent() method to calculate and return the monthly rent.
-The toString() method must return a string that will neatly display all the information to describes the object.

NOTE: Call the toString method from the super class. Then add salary and the allowance as the next two items to display.
Example:
Joe Bloom   0879678223   24   T   4   3   R19000
3. Write the subclass called BussProperty that inherits from the Property superclass
a)Declare the local instance fields.
b)Two constructors:
No arguments constructor
Parameterized constructor:
- Remember: Call the constructor of the super class using the super keyword.
c)Methods:
-Accessor methods for the instance fields.
- A method calcMonthRent() to calculate and return the monthly rent.
- A method calcMonthInsurance() to calculate and return the monthly insurance amount.
-A toString() method must return a string that will neatly display all the information to describes the object.
NOTE: Call the toString method from the super class..
Example:
Sue Smith  0723456872  12  280  R7000.00 R70000.0

4. Write a testProperties class:
Declare two ArrayLists – one for each type of property –arrResProp and arrBussProp
Create a FileClass class and write a method to read information from a text file called properties.txt into the two ArrayLists.
If the property is a residential property, create the object and add the object to the arrResProp ArrayList. If it is a business property, add the object to the arrBussProp ArrayList.
Example of the content of the text file:
R#Joe Bloom#0879678223#24#T#4#3
R#Sam Xaba#0849558202#12#F#2#1
B#Sue Smith#0723456872#12#280
R#Lee West#0826458288#12#H#3#2
B#John Pule#0723456872#24#320
B#Abe Thiem#0843412573#6#330
R#Craig Moore#0721236285#18#T#3#2
Write get methods to return the ArrayLists to the test class.
In the test class:
Write two static methods to display the information of the employees as two separate lists – one for residential and one for business properties.
The method must receive the ArrayList to display and its counter as parameters.
Also display suitable headings and subheadings.
Hint: Use a for loop and the toString() method in each method.
Call the methods from the main method.

Call the methods from the main method.
4
Residential Properties
Name
Cell num
Months
Туре
Beds
Baths
Rent (pm)
Joe Bloom
0879678223
24
T
4
3
R19000.00
Sam Xaba
0849558202
12
F
2
1
R9000.00
Lee West
0826458288
12
H
3
2
R14400.00
Craig Moore
0721236285
18
T
3
2
R18000.00
Business Properties
Name
Cell num
Months
Size
Insurance
Rent (pm)
Sue Smith
0723456872
12
280
R7000.00
R70000.00
John Pule
0723456872
24
320
R8000.00
R80000.00
Abe Thiem
0843412573
6
330
R8250.00
R82500.00
Transcribed Image Text:Call the methods from the main method. 4 Residential Properties Name Cell num Months Туре Beds Baths Rent (pm) Joe Bloom 0879678223 24 T 4 3 R19000.00 Sam Xaba 0849558202 12 F 2 1 R9000.00 Lee West 0826458288 12 H 3 2 R14400.00 Craig Moore 0721236285 18 T 3 2 R18000.00 Business Properties Name Cell num Months Size Insurance Rent (pm) Sue Smith 0723456872 12 280 R7000.00 R70000.00 John Pule 0723456872 24 320 R8000.00 R80000.00 Abe Thiem 0843412573 6 330 R8250.00 R82500.00
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
User Defined DataType
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education