public double matchPercentage(String user1, String user2) { db = new DataBaseWorker(connectionString); //get each users profile information Profile userOne = new Profile(); userOne = loadProfileFromDB(user1, userOne); Profile userTwo = new Profile(); userTwo = loadProfileFromDB(user2, userTwo); DatingProfile userOneWants = new DatingProfile(); userOneWants = loadDatingProfileFromDB(user1, userOneWants); DatingProfile userTwoWants = new DatingProfile(); userTwoWants = loadDatingProfileFromDB(user1, userTwoWants); //keep a running total of the total points double total_points = 0; //If height is in range add points (MAX 10) //check if userOne is in userTwos range if (userOne.Height_ft >= userTwoWants.Min_Height_ft && userOne.Height_ft <= userTwoWants.Max_Height_ft && userOne.Height_in >= userTwoWants.Min_Height_in && userOne.Height_in <= userTwoWants.Min_Height_in) { total_points += 10; } //check if userTwo is in userOnes range if (userTwo.Height_ft >= userOneWants.Min_Height_ft && userTwo.Height_ft <= userOneWants.Max_Height_ft && userTwo.Height_in >= userOneWants.Min_Height_in && userTwo.Height_in <= userOneWants.Min_Height_in) { total_points += 10; } //If weight is in range add points (MAX 10) //check if userOne is in userTwos range if (userOne.Weight >= userTwoWants.Min_Weight && userOne.Weight <= userTwoWants.Max_Weight) { total_points += 10; } //check if userTwo is in userOnes range if (userTwo.Weight >= userOneWants.Min_Weight && userTwo.Weight <= userOneWants.Max_Weight) { total_points += 10; } //If age is in range add points (MAX 10) //check if userOne is in userTwos range if (userOne.Age >= userTwoWants.Min_Age && userOne.Age <= userTwoWants.Max_Age) { total_points += 10; } //check if userTwo is in userOnes range if (userTwo.Age >= userOneWants.Min_Age && userTwo.Age <= userOneWants.Max_Age) { total_points += 10; } //10 points for race match if (userOne.Race == userTwoWants.Race) { total_points += 10; } if (userTwo.Race == userOneWants.Race) { total_points += 10; } //10 points for hair match if (userOne.Hair == userTwoWants.Hair) { total_points += 10; } if (userTwo.Hair == userOneWants.Hair) { total_points += 10; } //10 points for each matching interest if (userOne.Interest1 == userTwoWants.Interest1) { total_points += 10; } if (userTwo.Interest1 == userOneWants.Interest1) { total_points += 10; } //interest 2 if (userOne.Interest2 == userTwoWants.Interest2) { total_points += 10; } if (userTwo.Interest2 == userOneWants.Interest2) { total_points += 10; } //interest 3 if (userOne.Interest3 == userTwoWants.Interest3) { total_points += 10; } if (userTwo.Interest3 == userOneWants.Interest3) { total_points += 10; } return Math.Round((total_points / 160) * 100, 2); }
/// <summary> /// Default constructor; Initialize the DB connector /// </summary> public WorkerClass() { db = new DataBaseWorker(connectionString); }