コード例 #1
0
        private void speakNews(Mouth mouth, Interpreter interpreter, NewsApiTop newsAPI)
        {
            TopNews data = newsAPI.GetTopNews("gb");

            mouth.speakMsg(string.Format("The top 5 news stories today are:"));
            foreach (string story in interpreter.Top5(data))
            {
                mouth.speakMsg(string.Format(story));
            }
        }
コード例 #2
0
        public List <string> Top5(TopNews top)
        {
            List <string> returnData = new List <string>();
            int           count      = 5;

            foreach (Article article in top.articles)
            {
                if (count < 10)
                {
                    returnData.Add(article.title);
                    count++;
                }
                else
                {
                    continue;
                }
            }

            return(returnData);
        }