0% found this document useful (0 votes)
5 views4 pages

Real Estate Domain Java Code

The document defines a class hierarchy for properties, including a base class 'Property' and two derived classes 'ResidentialProperty' and 'CommercialProperty'. Each class contains attributes and methods for managing property details, such as ID, location, price, and specific features like number of bedrooms or office space. A 'TestClass' demonstrates the creation of instances of these classes and displays their information.

Uploaded by

247r1a6683
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Real Estate Domain Java Code

The document defines a class hierarchy for properties, including a base class 'Property' and two derived classes 'ResidentialProperty' and 'CommercialProperty'. Each class contains attributes and methods for managing property details, such as ID, location, price, and specific features like number of bedrooms or office space. A 'TestClass' demonstrates the creation of instances of these classes and displays their information.

Uploaded by

247r1a6683
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Property Class

class Property {
private String propertyId;
private String location;
private double price;

public Property(String propertyId, String location, double price) {


[Link] = propertyId;
[Link] = location;
[Link] = price;
}

public String getPropertyId() {


return propertyId;
}

public void setPropertyId(String propertyId) {


[Link] = propertyId;
}

public String getLocation() {


return location;
}

public void setLocation(String location) {


[Link] = location;
}

public double getPrice() {


return price;
}

public void setPrice(double price) {


[Link] = price;
}

public void displayPropertyInfo() {


[Link]("Property ID: " + propertyId);
[Link]("Location: " + location);
[Link]("Price: " + price);
}
}
ResidentialProperty Class
class ResidentialProperty extends Property {
private int numberOfBedrooms;
private double gardenSize;

public ResidentialProperty(String propertyId, String location, double price,


int numberOfBedrooms, double gardenSize) {
super(propertyId, location, price);
[Link] = numberOfBedrooms;
[Link] = gardenSize;
}

public int getNumberOfBedrooms() {


return numberOfBedrooms;
}

public void setNumberOfBedrooms(int numberOfBedrooms) {


[Link] = numberOfBedrooms;
}

public double getGardenSize() {


return gardenSize;
}

public void setGardenSize(double gardenSize) {


[Link] = gardenSize;
}

@Override
public void displayPropertyInfo() {
[Link]();
[Link]("Bedrooms: " + numberOfBedrooms);
[Link]("Garden Size: " + gardenSize);
}
}
CommercialProperty Class
class CommercialProperty extends Property {
private double officeSpace;
private boolean hasParking;

public CommercialProperty(String propertyId, String location, double price,


double officeSpace, boolean hasParking) {
super(propertyId, location, price);
[Link] = officeSpace;
[Link] = hasParking;
}

public double getOfficeSpace() {


return officeSpace;
}

public void setOfficeSpace(double officeSpace) {


[Link] = officeSpace;
}

public boolean isHasParking() {


return hasParking;
}

public void setHasParking(boolean hasParking) {


[Link] = hasParking;
}

@Override
public void displayPropertyInfo() {
[Link]();
[Link]("Office Space: " + officeSpace);
[Link]("Parking Available: " + hasParking);
}
}
TestClass (Main)
public class TestClass {
public static void main(String[] args) {

ResidentialProperty rp = new ResidentialProperty(


"R101", "Hyderabad", 7500000, 3, 500);

CommercialProperty cp = new CommercialProperty(


"C201", "Bangalore", 15000000, 2000, true);

[Link]();
[Link]();
}
}

You might also like