Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docs/appends/JPA_Before_Annotatons:_one-to-many-xml.md
db/apartmentpredictordb.mv.db.mv.db
db/apartmentpredictordb.mv.db.mv.db
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void run(String... args) throws Exception {
public void testApartmentsInsert() {
System.out.println("Creating apartment objects and saving to db...");
// Create apartment objects based on your sample data
Apartment apartment1 = new Apartment(
/*Apartment apartment1 = new Apartment(
13300000L, // price
7420, // area
4, // bedrooms
Expand All @@ -48,10 +48,10 @@ public void testApartmentsInsert() {
2, // parking
"yes", // prefarea
"furnished" // furnishingstatus
);
);*/

// Create additional sample apartments
Apartment apartment2 = new Apartment(
/*Apartment apartment2 = new Apartment(
8500000L, // price
5200, // area
3, // bedrooms
Expand Down Expand Up @@ -106,7 +106,7 @@ public void testApartmentsInsert() {
System.out.println(apartment);
}

//apartmentRepository.findAll().forEach(System.out::println);
//apartmentRepository.findAll().forEach(System.out::println);*/
}

public void testReviewsInsert() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,208 +7,52 @@
import java.util.UUID;

@Entity
public class Apartment {
public class Apartment extends ResidentialProperty {

@Id
private String id;
private Long price;
private Integer area;
private Integer bedrooms;
private Integer bathrooms;
private Integer stories;
private String mainroad;
private String guestroom;
private String basement;
private String hotwaterheating;
private String airconditioning;
private Integer parking;
private String prefarea;
private String furnishingstatus;

@OneToMany(
mappedBy = "apartment",
cascade = CascadeType.ALL,
fetch = FetchType.EAGER)
private List<Review> reviews = new ArrayList<>();

// Default constructor
public Apartment() {
this.id = UUID.randomUUID().toString();
}
private int floorLevel;
private boolean hasBalcony;

// Constructor with all fields
public Apartment(Long price, Integer area, Integer bedrooms, Integer bathrooms,
Integer stories, String mainroad, String guestroom, String basement,
String hotwaterheating, String airconditioning,
Integer parking, String prefarea, String furnishingstatus) {
this.id = UUID.randomUUID().toString();
this.price = price;
this.area = area;
this.bedrooms = bedrooms;
this.bathrooms = bathrooms;
this.stories = stories;
this.mainroad = mainroad;
this.guestroom = guestroom;
this.basement = basement;
this.hotwaterheating = hotwaterheating;
this.airconditioning = airconditioning;
this.parking = parking;
this.prefarea = prefarea;
this.furnishingstatus = furnishingstatus;
}

// helpers

public void addReview(Review review) {
reviews.add(review);
review.setApartment(this);
}

public void removeReview(Review review) {
reviews.remove(review);
review.setApartment(null);
}


// Getters and Setters
public Long getPrice() {
return price;
}

public void setPrice(Long price) {
this.price = price;
}

public Integer getArea() {
return area;
}

public void setArea(Integer area) {
this.area = area;
}

public Integer getBedrooms() {
return bedrooms;
}

public void setBedrooms(Integer bedrooms) {
this.bedrooms = bedrooms;
}

public Integer getBathrooms() {
return bathrooms;
}

public void setBathrooms(Integer bathrooms) {
this.bathrooms = bathrooms;
}

public Integer getStories() {
return stories;
}

public void setStories(Integer stories) {
this.stories = stories;
public Apartment(double area, String address, int locationRating, int numberOfBedrooms, int numberOfBathrooms, boolean hasGarden, boolean hasBalcony, int floorLevel) {
super(area, address, locationRating, numberOfBedrooms, numberOfBathrooms, hasGarden);
this.hasBalcony = hasBalcony;
this.floorLevel = floorLevel;
}

public String getMainroad() {
return mainroad;
}

public void setMainroad(String mainroad) {
this.mainroad = mainroad;
}

public String getGuestroom() {
return guestroom;
}

public void setGuestroom(String guestroom) {
this.guestroom = guestroom;
}

public String getBasement() {
return basement;
}

public void setBasement(String basement) {
this.basement = basement;
}

public String getHotwaterheating() {
return hotwaterheating;
}

public void setHotwaterheating(String hotwaterheating) {
this.hotwaterheating = hotwaterheating;
}

public String getAirconditioning() {
return airconditioning;
}

public void setAirconditioning(String airconditioning) {
this.airconditioning = airconditioning;
}

public Integer getParking() {
return parking;
public Apartment() {
super();
}

public void setParking(Integer parking) {
this.parking = parking;
}

public String getPrefarea() {
return prefarea;
}
// helpers

public void setPrefarea(String prefarea) {
this.prefarea = prefarea;
}

public String getFurnishingstatus() {
return furnishingstatus;
// Getters and Setters
public int getFloorLevel() {
return floorLevel;
}

public void setFurnishingstatus(String furnishingstatus) {
this.furnishingstatus = furnishingstatus;
public void setFloorLevel(int floorLevel) {
this.floorLevel = floorLevel;
}

public String getId() {
return id;
public boolean hasBalcony() {
return hasBalcony;
}

/*public void setId(String id) {
this.id = id;
}*/

public List<Review> getReviews() {
return reviews;
public void setHasBalcony(boolean hasBalcony) {
this.hasBalcony = hasBalcony;
}

public void setReviews(List<Review> reviews) {
this.reviews = reviews;
@Override
public double calculatePrice() {
return 750;
}

@Override
public String toString() {
return "Apartment{" +
"id=" + id +
", price=" + price +
", area=" + area +
", bedrooms=" + bedrooms +
", bathrooms=" + bathrooms +
", stories=" + stories +
", mainroad='" + mainroad + '\'' +
", guestroom='" + guestroom + '\'' +
", basement='" + basement + '\'' +
", hotwater='" + hotwaterheating + '\'' +
", airconditioning='" + airconditioning + '\'' +
", parking=" + parking +
", prefarea='" + prefarea + '\'' +
", furnishingstatus='" + furnishingstatus + '\'' +
", reviews='" + reviews.size() + '\'' +
'}';
public boolean requiresHomeownersAssociation() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.example.apartment_predictor.model;

public class Duplex extends SingleFamilyHome {

private boolean hasSeparateUtilities;
private int units;

public Duplex(double area, String address, int locationRating, int numberOfBedrooms, int numberOfBathrooms, boolean hasGarden, double lotSize, boolean hasGarage, boolean hasPool, boolean appropiateForPets, boolean appropiateForChildren, double hoaMonthlyFee, boolean hasSeparateUtilities) {
super(area, address, locationRating, numberOfBedrooms, numberOfBathrooms, hasGarden, lotSize, hasGarage, hasPool, appropiateForPets, appropiateForChildren, hoaMonthlyFee);
this.hasSeparateUtilities = hasSeparateUtilities;
this.units = 2;
}

public boolean isHasSeparateUtilities() {
return hasSeparateUtilities;
}

public void setHasSeparateUtilities(boolean hasSeparateUtilities) {
this.hasSeparateUtilities = hasSeparateUtilities;
}

public int getUnits() {
return units;
}

@Override
public double calculatePrice() {
return numberOfBedrooms * 200 + hoaMonthlyFee;
}

@Override
public boolean requiresHomeownersAssociation() {
return appropiateForChildren || appropiateForPets || calculatePrice() < 1000 || area < 50;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.example.apartment_predictor.model;

public class House extends SingleFamilyHome{

private boolean hasBasement;
private double basementArea;

public House(double area, String address, int locationRating, int numberOfBedrooms, int numberOfBathrooms, boolean hasGarden, double lotSize, boolean hasGarage, boolean hasPool, boolean appropiateForPets, boolean appropiateForChildren, double hoaMonthlyFee, boolean hasBasement, double basementArea) {
super(area, address, locationRating, numberOfBedrooms, numberOfBathrooms, hasGarden, lotSize, hasGarage, hasPool, appropiateForPets, appropiateForChildren, hoaMonthlyFee);
this.hasBasement = hasBasement;
this.basementArea = basementArea;
}

public boolean isHasBasement() {
return hasBasement;
}

public void setHasBasement(boolean hasBasement) {
this.hasBasement = hasBasement;
}

public double getBasementArea() {
return basementArea;
}

public void setBasementArea(double basementArea) {
this.basementArea = basementArea;
}

@Override
public double calculatePrice() {
return numberOfBedrooms * 125 + hoaMonthlyFee + basementArea * 2;
}

@Override
public boolean requiresHomeownersAssociation() {
return appropiateForChildren || appropiateForPets || calculatePrice() < 1000 || area < 50 || basementArea > 20;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

package com.example.apartment_predictor.model;

/**
*
* @author Alumne_mati1
*/
abstract public class Property {
protected double area;
protected String address;
protected int locationRating;

public Property(double area, String address, int locationRating) {
this.area = area;
this.address = address;
this.locationRating = locationRating;
}

public Property() {

}

public double getArea() {
return area;
}

public void setArea(double area) {
this.area = area;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public int getLocationRating() {
return locationRating;
}

public void setLocationRating(int locationRating) {
this.locationRating = locationRating;
}

abstract public double calculatePrice();
}
Loading