Advertisement
minhnhatisme

Untitled

May 11th, 2021
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7.  
  8. namespace WebApp
  9. {
  10.     class Program
  11.     {
  12.  
  13.         static void DisplayFeeds(List<string> feeds, Dictionary<string, string> covid19Info)
  14.         {
  15.             int i = 0;
  16.             while(i < feeds.Count)
  17.             {
  18.                 if(i == feeds.Count - 1)
  19.                 {
  20.                     i = 0;
  21.                 }
  22.                 else if(i % 2 == 0 && i % 5 == 0)
  23.                 {
  24.                     DisplayCovid19Info(covid19Info);
  25.                 }
  26.                 Thread.Sleep(1000);
  27.                 Console.WriteLine("Tin tức mới nhất: " + feeds[i]);
  28.                 i++;
  29.             }
  30.         }
  31.  
  32.         static void DisplayCovid19Info(Dictionary<string, string> info)
  33.         {
  34.             string[] content =
  35.             {
  36.                 "",
  37.                 "==============================================",
  38.                 ">> THẾ GIỚI",
  39.                 "Số ca mắc: " + info["WorldTotalConfirmed"],
  40.                 "Số ca tử vong: " + info["WorldTotalDeaths"],
  41.                 "Số ca hồi phục: " + info["WorldTotalRecovered"],
  42.                 "==============================================",
  43.                 ">> VIỆT NAM",
  44.                 "Số ca mắc: " + info["VietnamTotalConfirmed"],
  45.                 "Số ca tử vong: " + info["VietnamTotalDeaths"],
  46.                 "Số ca hồi phục: " + info["VietnamTotalRecovered"],
  47.                 "==============================================",
  48.                 "",
  49.             };
  50.             Console.WriteLine(string.Join("\n", content));
  51.         }
  52.  
  53.         static void Main(string[] args)
  54.         {
  55.             Console.OutputEncoding = Encoding.UTF8;
  56.             Modules.ReadFeeds readFeeds = new Modules.ReadFeeds();
  57.             var feeds = readFeeds.ReadRssFeed();
  58.             var covid19Info = readFeeds.GetCovid19Info();
  59.             DisplayFeeds(feeds, covid19Info);
  60.         }
  61.     }
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement