svetlozar_kirkov

Random Advertising (Exercise)

Oct 8th, 2014
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleTests
  6. {
  7.     class ConsoleTests
  8.     {
  9.         private static List<string> phrases = new List<string>()
  10.         {
  11.             "The product is excellent.",
  12.             "This is a great product.",
  13.             "I use this product constantly.",
  14.             "This is the best product from this category."
  15.         };
  16.  
  17.         private static List<string> stories = new List<string>()
  18.         {
  19.             "Now I feel better.",
  20.             "I managed to change.",
  21.             "It made some miracle.",
  22.             "I can’t believe it, but now I am feeling great.",
  23.             "You should try it, too. I am very satisfied."
  24.         };
  25.  
  26.         private static List<string> firstNames = new List<string>()
  27.         {
  28.             "Dayan",
  29.             "Stella",
  30.             "Hellen",
  31.             "Kate"
  32.         };
  33.  
  34.         private static List<string> lastNames = new List<string>()
  35.         {
  36.             "Johnson",
  37.             "Peterson",
  38.             "Charls"
  39.         };
  40.  
  41.         private static List<string> cities = new List<string>()
  42.         {
  43.             "London",
  44.             "Paris",
  45.             "Berlin",
  46.             "New York",
  47.             "Madrid"
  48.         };
  49.         static void Main()
  50.         {
  51.             var GlobalStrings = new List<List<string>>();
  52.             GlobalStrings.Add(phrases);
  53.             GlobalStrings.Add(stories);
  54.             GlobalStrings.Add(firstNames);
  55.             GlobalStrings.Add(lastNames);
  56.             GlobalStrings.Add(cities);
  57.  
  58.             Random test = new Random();
  59.             List<string> result = new List<string>();
  60.             foreach (var globalString in GlobalStrings)
  61.             {
  62.                 int index = test.Next(globalString.Count());
  63.                 result.Add(globalString[index]);
  64.             }
  65.  
  66.             Console.WriteLine("{0} {1} -- {2} {3}, {4}", result[0],result[1],result[2],result[3],result[4]);
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment