-
Notifications
You must be signed in to change notification settings - Fork 0
/
User.java
34 lines (27 loc) · 1.24 KB
/
User.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.example.griffin.housematch;
public class User extends Properties {
int[] primes = {2, 3, 5, 7, 11, 13};
//Constructor
User (int total_bedrooms, int open_bedrooms, int bathrooms, float distance,
float max_price, int sqft, int[] priority) {
super(total_bedrooms, open_bedrooms, bathrooms, distance, max_price,
sqft, priority);
this.type = "User";
}
public float rank (House house) {
if( house.distance > this.distance || house.max_price > this.max_price || this.sqft > house.sqft) {
return 0;
}
float sum = 0;
sum += this.weight(this.priority[0]) * 1.0 / (1 + (Math.abs(house.total_bedrooms - this.total_bedrooms)));
sum += this.weight(this.priority[1]) * 1.0 / (1 + (Math.abs(house.open_bedrooms - this.open_bedrooms)));
sum += this.weight(this.priority[2]) * (house.bathrooms - this.bathrooms);
sum += this.weight(this.priority[4]) * 1.0 / (1 + (house.distance));
sum += this.weight(this.priority[3]) * 1.0 / (1 + ((house.max_price) / 1000));
sum += this.weight(this.priority[5]) * ((float)(house.sqft - this.sqft) / 200 );
return sum;
}
public int weight (int priority) {
return primes[6 - priority];
}
}