public ActionResult Index(bool goodWithChildren, bool drools, ELength coatlength, EScale activityLevel, EScale sheddingLevel, EScale groomingLevel, EScale intelligenceLevel, ESize size) { Dog requestedDog = new Dog { GoodWithChildren = goodWithChildren, Drools = drools, Coatlength = coatlength, ActivityLevel = activityLevel, SheddingLevel = sheddingLevel, GroomingLevel = groomingLevel, IntelligenceLevel = intelligenceLevel, Size = size }; Dog returnDog = findDogRecommendation(requestedDog); if (returnDog.BreedName != null) { return(View("DogRecommendation", returnDog)); } else { return(View("NoDogRecommendation")); } }
private int determineBestMatch(bool GoodWithChildren, bool Drools, ELength Coatlength, ESize Size, EScale ActivityLevel, EScale SheddingLevel, EScale GroomingLevel, EScale IntelligenceLevel) { //Make a list to store score values. This is a way of assessing which dog is the best choice. int[] scores = new int[dogList.Count]; for (int i = 0; i < dogList.Count; i++) { //For each matching criteria, increase a score value. //This completely hinges on the fact that dogs in the list ARE NOT SORTED. //The dog list has a very tenuous connection with the score list. if (dogList[i].GoodWithChildren == GoodWithChildren) { scores[i]++; } if (dogList[i].Drools == Drools) { scores[i]++; } if (dogList[i].Coatlength == Coatlength) { scores[i]++; } if (dogList[i].Size == Size) { scores[i]++; } if (dogList[i].ActivityLevel == ActivityLevel) { scores[i]++; } if (dogList[i].SheddingLevel == SheddingLevel) { scores[i]++; } if (dogList[i].GroomingLevel == GroomingLevel) { scores[i]++; } if (dogList[i].IntelligenceLevel == IntelligenceLevel) { scores[i]++; } } //Get max val int highScore = scores.Max(); //Big Caveat: //This will return the index of the first dog that achieved that score. //It's quite common for multiple dogs to get the same score, so some dogs will be over-represented in practice. //This can be prevented by instead creating a list of dogs with equal scores and randomly selecting one from there as the //return dog. I felt it wasn't needed for the scope of this practical (also it's 11:30pm). int indexOf = scores.ToList().IndexOf(highScore); //Return index return indexOf; }
public ActionResult ChooseDogPref(bool GoodWithChildren, bool Drools, ELength Coatlength, ESize Size, EScale ActivityLevel, EScale SheddingLevel, EScale GroomingLevel, EScale IntelligenceLevel) { //Call makedatabase, populating a list of dogs dogList = makeDatabase(); //Blank dog object, will be passed into the return view Dog recDog = dogList[0]; //build a return dog by determining the index of the best match. int indexOfBest = determineBestMatch(GoodWithChildren, Drools, Coatlength, Size, ActivityLevel, SheddingLevel, GroomingLevel, IntelligenceLevel); recDog = dogList[indexOfBest]; return View("DogConfirm", recDog); }
//if values are the same assign 1 //if it is not medium means must be either short or long //and if the list dog is medium assigns .5 for close public double getELengthValue(ELength wantedDogInput, ELength listDogInput) { double value = 0; if(wantedDogInput == listDogInput) { value = 1; } if((wantedDogInput != ELength.Medium)&&(listDogInput == ELength.Medium)) { value = 0.5; } return value; }
//if values are the same assign 1 //if it is not medium means must be either short or long //and if the list dog is medium assigns .5 for close public double getELengthValue(ELength wantedDogInput, ELength listDogInput) { double value = 0; if (wantedDogInput == listDogInput) { value = 1; } if ((wantedDogInput != ELength.Medium) && (listDogInput == ELength.Medium)) { value = 0.5; } return(value); }
public ActionResult Result(EScale activityLevel, ELength coatlength, bool drools, bool goodWithChildren, EScale groomingLevel, EScale intelligenceLevel, EScale sheddingLevel, ESize size) { List<Dog> dogs = makeDatabase(); //gets dogs databse //creates dog with properties submitted in by user in html form Dog userDog = new Dog(); userDog.ActivityLevel = activityLevel; userDog.Coatlength = coatlength; userDog.Drools = drools; userDog.GoodWithChildren = goodWithChildren; userDog.GroomingLevel = groomingLevel; userDog.IntelligenceLevel = intelligenceLevel; userDog.SheddingLevel = sheddingLevel; userDog.Size = size; //userDog is set to its best match userDog = findClosestDog(userDog); return View(userDog); }
public ActionResult Result(EScale activityLevel, ELength coatlength, bool drools, bool goodWithChildren, EScale groomingLevel, EScale intelligenceLevel, EScale sheddingLevel, ESize size) { List <Dog> dogs = makeDatabase(); //gets dogs databse //creates dog with properties submitted in by user in html form Dog userDog = new Dog(); userDog.ActivityLevel = activityLevel; userDog.Coatlength = coatlength; userDog.Drools = drools; userDog.GoodWithChildren = goodWithChildren; userDog.GroomingLevel = groomingLevel; userDog.IntelligenceLevel = intelligenceLevel; userDog.SheddingLevel = sheddingLevel; userDog.Size = size; //userDog is set to its best match userDog = findClosestDog(userDog); return(View(userDog)); }
public ActionResult Index(bool goodWithChildren, bool drools, ELength coatlength, EScale activityLevel, EScale sheddingLevel, EScale groomingLevel, EScale intelligenceLevel, ESize size) { Dog requestedDog = new Dog { GoodWithChildren = goodWithChildren, Drools = drools, Coatlength = coatlength, ActivityLevel = activityLevel, SheddingLevel = sheddingLevel, GroomingLevel = groomingLevel, IntelligenceLevel = intelligenceLevel, Size = size }; Dog returnDog = findDogRecommendation(requestedDog); if (returnDog.BreedName != null) return View("DogRecommendation", returnDog); else return View("NoDogRecommendation"); }
public ActionResult ShowSelect(bool GoodWithChildren, bool Drooling, ELength CoatLength, EScale ActivityLevel, EScale SheddingLevel, EScale GroomingLevel, EScale IntelligenceLevel, ESize Size) { //makes the wanted dog Dog wantedDog = new Dog { ActivityLevel = ActivityLevel, SheddingLevel = SheddingLevel, GroomingLevel = GroomingLevel, IntelligenceLevel = IntelligenceLevel, GoodWithChildren = GoodWithChildren, Drools = Drooling, CoatLength = CoatLength, Size = Size }; //calls method to find closest dog Dog closestMatch = findClosestMatch(wantedDog); //returns the view and dog return(View("DogRecomendation", closestMatch)); }
public ActionResult SelectedDog(EScale activityLevel, EScale sheddingLevel, EScale groomingLevel, EScale intelligenceLevel, ELength coatlength, ESize size, bool goodWithChildren, bool drools) { DatabaseManager dbm = new DatabaseManager(); db = dbm.makeDatabase(); Dog nDog = new Dog(); nDog.ActivityLevel = activityLevel; nDog.SheddingLevel = sheddingLevel; nDog.GroomingLevel = groomingLevel; nDog.IntelligenceLevel = intelligenceLevel; nDog.Coatlength = coatlength; nDog.Size = size; nDog.GoodWithChildren = goodWithChildren; nDog.Drools = drools; nDog.BreedName = db[0].BreedName; nDog.ImageName = db[0].ImageName; nDog.DisplayName = db[0].DisplayName; Dog recommendation = dbm.FindRecommodation(db, nDog); return View(recommendation); }
public ActionResult ShowSelect(bool GoodWithChildren, bool Drooling, ELength CoatLength, EScale ActivityLevel, EScale SheddingLevel, EScale GroomingLevel, EScale IntelligenceLevel, ESize Size) { //makes the wanted dog Dog wantedDog = new Dog { ActivityLevel = ActivityLevel, SheddingLevel = SheddingLevel, GroomingLevel = GroomingLevel, IntelligenceLevel = IntelligenceLevel, GoodWithChildren = GoodWithChildren, Drools = Drooling, CoatLength = CoatLength, Size = Size }; //calls method to find closest dog Dog closestMatch = findClosestMatch(wantedDog); //returns the view and dog return View("DogRecomendation", closestMatch); }