public double CheckDislikedMakes(Car car, Dictionary <int, Answer> answers) { Answer_List_String answer = answers[DISLIKEDCARMAKES_INDEX] as Answer_List_String; List <String> answerValue = answer.AnswerValue() as List <String>; double rating; double importance = ((double)answer.Importance()) / 5.0; if (!answerValue.Contains(car.Make)) { rating = 1.0; } else { rating = 0; } return(rating * importance); }
public double CheckPrefCarType(Car car, Dictionary <int, Answer> answers) { Answer_List_String answer = answers[PREFCARTYPE_INDEX] as Answer_List_String; List <String> answerValue = answer.AnswerValue() as List <String>; double rating; double importance = ((double)answer.Importance()) / 5.0; if (answerValue.Contains(car.CarType)) { rating = 1.0; } else { rating = 0; } return(rating * importance); }
public double CheckTransmission(Car car, Dictionary <int, Answer> answers) { Answer_List_String answer = answers[TRANSMISSION_INDEX] as Answer_List_String; List <String> answerValue = answer.AnswerValue() as List <String>; double rating; double importance = ((double)answer.Importance()) / 5.0; if (answerValue.Contains(car.Transmission)) { rating = 1.0; } else { rating = 0.0; } return(rating * importance); }
public double CheckEnginTypeAndCylinder(Car car, Dictionary <int, Answer> answers) { Answer_1_String answer = answers[PRIMARYDRIVINGENVIRONMENT_INDEX] as Answer_1_String; double rating; double importance = ((double)answer.Importance()) / 5.0; String userInput = answer.AnswerValue().ToString(); if (userInput == car.EngineType) { rating = 1.0; } else { rating = 0.0; } double currentRating = rating * importance; double possibleCylinderRating = 0.0; if (answers.ContainsKey(CYLINDERCOUNT_INDEX)) { Answer_List_String cylinderAnswer = answers[CYLINDERCOUNT_INDEX] as Answer_List_String; List <String> answerValue = cylinderAnswer.AnswerValue() as List <String>; rating = 0.0; importance = (double)cylinderAnswer.Importance() / 5.0; if (answerValue.Contains(car.EngineConstruction)) { rating = 1.0; } possibleCylinderRating = rating * importance; } return(currentRating + possibleCylinderRating); }
public double CheckHorsePower(Car car, Dictionary <int, Answer> answers) { Answer_List_String answer = answers[HORSEPOWER_INDEX] as Answer_List_String; List <String> answerValue = answer.AnswerValue() as List <String>; double rating; double importance = ((double)answer.Importance()) / 5.0; double upperRange; double upper; double lowerRange; double lower; //ToDo: Handle if answer is 600+ if (answerValue[0] == "600+") { lowerRange = 600; upperRange = 100000; } else { string[] elements = answerValue[0].Split('-'); lowerRange = Double.Parse(elements[0]); upperRange = Double.Parse(elements[1]); } for (int i = 1; i < answerValue.Count; i++) { string s = answerValue[i]; double tempLower; double tempUpper; if (s == "600+") { tempLower = 600; tempUpper = 100000; } else { string [] elements = s.Split('-'); tempLower = Double.Parse(elements[0]); tempUpper = Double.Parse(elements[1]); } if (tempLower < lowerRange) { lowerRange = tempLower; } if (tempUpper > upperRange) { upperRange = tempUpper; } } lower = lowerRange * 0.8; upper = upperRange * 1.2; double x = car.Horsepower; if (x <= lower) { rating = 0; } else if (x > lower && x < lowerRange) { rating = 1 / (lowerRange - lower) * (x - lower); } else if (x >= lowerRange && x <= upperRange) { rating = 1; } else if (x > upperRange && x <= upper) { rating = -1 / (upper - upperRange) * (x - upperRange) + 1; } else { rating = 0; } return(rating * importance); }
public double MaximumScore(Dictionary <int, Answer> answers) { Dictionary <int, double> tempAnswers = new Dictionary <int, double>(); foreach (KeyValuePair <int, Answer> kvp in answers) { double imp = (double)kvp.Value.Importance(); tempAnswers.Add(kvp.Key, imp); } if (!tempAnswers.ContainsKey(FUELECONOMY_INDEX)) { tempAnswers.Remove(FUELECONOMY_INDEX); } else { Answer_1_String ans = answers[FUELECONOMY_INDEX] as Answer_1_String; String ui = ans.AnswerValue().ToString(); if (ui == "Egal") { tempAnswers.Remove(FUELECONOMY_INDEX); } } if (!answers.ContainsKey(CYLINDERCOUNT_INDEX)) { tempAnswers.Remove(CYLINDERCOUNT_INDEX); } else { Answer_List_String cylinderAnswer = answers[CYLINDERCOUNT_INDEX] as Answer_List_String; List <String> answerValue = cylinderAnswer.AnswerValue() as List <String>; if (answerValue.Contains("Nein")) { tempAnswers.Remove(CYLINDERCOUNT_INDEX); } } if (!answers.ContainsKey(CHILDSEAT_INDEX)) { tempAnswers.Remove(CHILDSEAT_INDEX); } else { Answer_1_String childSeatAnswer = null; childSeatAnswer = answers[CHILDSEAT_INDEX] as Answer_1_String; String childSeatAnswerValue = childSeatAnswer.AnswerValue().ToString(); if (childSeatAnswerValue == "Nein") { tempAnswers.Remove(CHILDSEAT_INDEX); } } Answer_1_String answer = answers[BUGET_INDEX] as Answer_1_String; String userInput = answer.AnswerValue().ToString(); if (userInput == "Egal") { tempAnswers.Remove(BUGET_INDEX); } answer = answers[ACCELERATION_INDEX] as Answer_1_String; userInput = answer.AnswerValue().ToString(); if (userInput == "Egal") { tempAnswers.Remove(ACCELERATION_INDEX); } double temp = 0; foreach (double a in tempAnswers.Values) { double imp = (double)a / 5.0; temp += imp; } return(temp); }