Advertisement
YavorGrancharov

Websites(class)

Jul 23rd, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Websites
  6. {
  7.     class Program
  8.     {
  9.         class Website
  10.         {
  11.             public string Host { get; set; }
  12.  
  13.             public string Domain { get; set; }
  14.  
  15.             public List<string> Queries { get; set; }
  16.         }
  17.  
  18.         static void Main(string[] args)
  19.         {
  20.             List<Website> data = new List<Website>();
  21.  
  22.             string input = Console.ReadLine();
  23.  
  24.             while (input != "end")
  25.             {
  26.                 string[] tokens = input
  27.                     .Split(new string[] { " | " },
  28.                     StringSplitOptions.RemoveEmptyEntries);
  29.  
  30.                 string host = tokens[0];
  31.                 string domain = tokens[1];
  32.                 List<string> queries;
  33.  
  34.                 if (tokens.Length > 2)
  35.                 {
  36.                     queries = tokens[2].Split(',').ToList();
  37.                 }
  38.                 else
  39.                 {
  40.                     queries = new List<string>();
  41.                 }
  42.  
  43.                 Website newWebData = new Website
  44.                 {
  45.                     Host = host,
  46.                     Domain = domain,
  47.                     Queries = queries
  48.                 };
  49.  
  50.                 data.Add(newWebData);
  51.  
  52.                 input = Console.ReadLine();
  53.             }
  54.  
  55.             foreach (var info in data)
  56.             {
  57.                 Console.Write("https://www.{0}.{1}",
  58.                     info.Host, info.Domain);
  59.  
  60.                 if (info.Queries.Count > 0)
  61.                 {
  62.                     Console.Write("/query?=[{0}]",
  63.                         string.Join("]&[", info.Queries));
  64.                 }
  65.                 Console.WriteLine();
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement