Exemplo n.º 1
0
        public string getJoke()
        {
            string hereItIs = "";
            int    numJokes = Settings.Default.JokeList.Count;
            int    indx     = rand.Next(0, numJokes);
            bool   allSeen  = checkAllSeen();

            if (allSeen)
            {
                JokeResult.Hide();
                RestartButton.Show();
                Notification.Text    = "You've seen all the jokes!";
                JokeResult.BackColor = Color.BlanchedAlmond;
                JokeButton.Hide();
                Like.Hide();
                Dislike.Hide();
            }
            else
            {
                if (Settings.Default.JokeSeen[indx] == "0")
                {
                    hereItIs = Settings.Default.JokeList[indx].ToString();
                    string jokeVal = Settings.Default.LikeOrDislike[indx].ToString();
                    if (jokeVal == "+")
                    {
                        JokeResult.BackColor = Color.OliveDrab;
                        Notification.Text    = "You liked this joke...";
                    }
                    if (jokeVal == "-")
                    {
                        JokeResult.BackColor = Color.IndianRed;
                        Notification.Text    = "You disliked this joke...";
                    }
                }
                else
                {
                    hereItIs = findNextUnseen();
                }

                Settings.Default.CurrentJoke    = indx;
                Settings.Default.JokeSeen[indx] = "1";
                Settings.Default.Save();
            }
            return(hereItIs);
        }