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); }