In: Computer Science
IN JAVA OOP
Design and build objects to be used by a real estate company for listing the properties for sale. A base object of a property is necessary. Decide what common about all properties and include these in the property object. Different type of properties are land, commercial and residential. A residential property can be single family and multi family. A commercial can be a commercial can be either a farm or non-farm.
Look at real estate websites and decide what to include in each object. Provide the UML that shows the objects and the relationship. Write the code for all the objects and submit hard copy of the UML and the code.
import java.awt.Image;
import java.util.ArrayList;
class Property {
protected int length;
protected int width;
protected String owner, address, ownerPhone,
typeOfOwnership;
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getOwnerPhone() {
return ownerPhone;
}
public void setOwnerPhone(String ownerPhone) {
this.ownerPhone = ownerPhone;
}
public String getTypeOfOwnership() {
return typeOfOwnership;
}
public void setTypeOfOwnership(String typeOfOwnership)
{
this.typeOfOwnership =
typeOfOwnership;
}
public long getPrice() {
return price;
}
public void setPrice(long price) {
this.price = price;
}
public long getAgeOfProperty() {
return ageOfProperty;
}
public void setAgeOfProperty(long ageOfProperty)
{
this.ageOfProperty =
ageOfProperty;
}
protected long price;
protected long ageOfProperty;
}
class Land extends Property {
}
class Commercial extends Property {
protected String electricityAvailability,
waterAvailability;
public String getElectricityAvailability() {
return
electricityAvailability;
}
public void setElectricityAvailability(String
electricityAvailability) {
this.electricityAvailability =
electricityAvailability;
}
public String getWaterAvailability() {
return waterAvailability;
}
public void setWaterAvailability(String
waterAvailability) {
this.waterAvailability =
waterAvailability;
}
}
class Farm extends Commercial {
protected boolean rainWaterHarvesting;
protected ArrayList suitableForCrops;
public boolean isRainWaterHarvesting() {
return rainWaterHarvesting;
}
public void setRainWaterHarvesting(boolean
rainWaterHarvesting) {
this.rainWaterHarvesting =
rainWaterHarvesting;
}
public ArrayList getSuitableForCrops() {
return suitableForCrops;
}
public void setSuitableForCrops(ArrayList
suitableForCrops) {
this.suitableForCrops =
suitableForCrops;
}
}
class NonFarm extends Commercial {
protected boolean currentlyLeasedOut;
public boolean isCurrentlyLeasedOut() {
return currentlyLeasedOut;
}
public void setCurrentlyLeasedOut(boolean
currentlyLeasedOut) {
this.currentlyLeasedOut =
currentlyLeasedOut;
}
public String getSuitableFor() {
return suitableFor;
}
public void setSuitableFor(String suitableFor) {
this.suitableFor =
suitableFor;
}
protected String suitableFor;
}
class Residential extends Property {
protected String furnishing, possesion, condition;
public String getFurnishing() {
return furnishing;
}
public void setFurnishing(String furnishing)
{
this.furnishing = furnishing;
}
public String getPossesion() {
return possesion;
}
public void setPossesion(String possesion) {
this.possesion = possesion;
}
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
}
class Single extends Residential {
protected int numBedrooms, numBathrooms;
protected boolean hall, kitchen, petsAllowed;
public int getNumBedrooms() {
return numBedrooms;
}
public void setNumBedrooms(int numBedrooms) {
this.numBedrooms =
numBedrooms;
}
public int getNumBathrooms() {
return numBathrooms;
}
public void setNumBathrooms(int numBathrooms) {
this.numBathrooms =
numBathrooms;
}
public boolean isHall() {
return hall;
}
public void setHall(boolean hall) {
this.hall = hall;
}
public boolean isKitchen() {
return kitchen;
}
public void setKitchen(boolean kitchen) {
this.kitchen = kitchen;
}
public boolean isPetsAllowed() {
return petsAllowed;
}
public void setPetsAllowed(boolean petsAllowed)
{
this.petsAllowed =
petsAllowed;
}
}
class MultiFamily extends Residential {
protected Image FloorPlan;
protected int numberOfFlats;
public int getNumberOfFlats() {
return numberOfFlats;
}
public void setNumberOfFlats(int numberOfFlats)
{
this.numberOfFlats =
numberOfFlats;
}
}