NinaSmith

Untitled

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