private static int compareUserSongWithRappers(Rapper eminemSwearStats, UserInput song) { int score = 0; foreach (var myWords in song.swearsFromUser) { if (eminemSwearStats.swears.ContainsKey(myWords.Key)) { score++; } /*else * { * score--; * }*/ } return(score); }
private void Button_Click(object sender, EventArgs e) { var userText = richTextBox1.Text; var uknownSong = new UserInput(userText); var eminemSwearStats = new Rapper("Eminem"); eminemSwearStats.AddSong("stan"); eminemSwearStats.AddSong("Lose Yourself"); eminemSwearStats.AddSong("Venom"); eminemSwearStats.AddSong("Lucky you"); var twoPacStats = new Rapper("2pac"); twoPacStats.AddSong("changes"); twoPacStats.AddSong("Dear Mama"); twoPacStats.AddSong("Hit Em Up"); twoPacStats.AddSong("California Love"); twoPacStats.AddSong("Ghetto Gospel"); var huStats = new Rapper("Hollywood Undead"); huStats.AddSong("undead"); huStats.AddSong("Christmas in hollywood"); huStats.AddSong("Comin' in Hot"); huStats.AddSong("No. 5"); huStats.AddSong("City"); var snoopDoggStats = new Rapper("Snoop dogg"); snoopDoggStats.AddSong("Bitch please"); snoopDoggStats.AddSong("Who Am I"); snoopDoggStats.AddSong("Vato"); snoopDoggStats.AddSong("Gin and Juice"); snoopDoggStats.AddSong("Lay Low"); var DMXstats = new Rapper("DMX"); DMXstats.AddSong("x gon give it to ya"); DMXstats.AddSong("Party up"); DMXstats.AddSong("Who we be"); DMXstats.AddSong("No sunshine"); DMXstats.AddSong("I miss you"); var EminemScore = compareUserSongWithRappers(eminemSwearStats, uknownSong); var twoPacScore = compareUserSongWithRappers(twoPacStats, uknownSong); var hollywoodUndeadScore = compareUserSongWithRappers(huStats, uknownSong); var snoopDoggScore = compareUserSongWithRappers(snoopDoggStats, uknownSong); var DMXscore = compareUserSongWithRappers(DMXstats, uknownSong); List <MyData> myRappers = new List <MyData>(); myRappers.Add(new MyData { score = EminemScore, rapper = "Eminem" }); myRappers.Add(new MyData { score = twoPacScore, rapper = "2Pac" }); myRappers.Add(new MyData { score = hollywoodUndeadScore, rapper = "Hollywood Undead" }); myRappers.Add(new MyData { score = snoopDoggScore, rapper = "Snoop Dogg" }); myRappers.Add(new MyData { score = DMXscore, rapper = "DMX" }); var bubbleSortedList = czaryMary(myRappers); if (bubbleSortedList[4].score == 0) { label2.Text = "Without swears it's imposible to me what this song name is"; } else { label2.Text = "That probably's " + bubbleSortedList[4].rapper + " (" + bubbleSortedList[4].score + ")"; label3.Text = "2." + bubbleSortedList[3].rapper + " (" + bubbleSortedList[3].score + ")"; label4.Text = "3." + bubbleSortedList[2].rapper + " (" + bubbleSortedList[2].score + ")"; label5.Text = "4." + bubbleSortedList[1].rapper + " (" + bubbleSortedList[1].score + ")"; label6.Text = "5." + bubbleSortedList[0].rapper + " (" + bubbleSortedList[0].score + ")"; } }