petaryankov00

Untitled

Apr 3rd, 2021
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.66 KB | None | 0 0
  1. using EasterRaces.Core.Contracts;
  2. using EasterRaces.IO;
  3. using EasterRaces.IO.Contracts;
  4. using EasterRaces.Core.Entities;
  5. using System;
  6.  
  7. namespace EasterRaces
  8. {
  9.     public class StartUp
  10.     {
  11.         public static void Main()
  12.         {
  13.             //IChampionshipController controller = null; //new ChampionshipController();
  14.             //IReader reader = new ConsoleReader();
  15.             //IWriter writer = new ConsoleWriter();
  16.  enigne = new Engine(controller, reader, writer);
  17.             //enigne.Run();
  18.  
  19.             //Engine
  20.             string text = Console.ReadLine();
  21.  
  22.             while (true)
  23.             {
  24.                 string line = Console.ReadLine();
  25.                 if (line == "Done")
  26.                 {
  27.                     break;
  28.                 }
  29.  
  30.                 string[] parts = line.Split(" ", StringSplitOptions.RemoveEmptyEntries);
  31.                 string command = parts[0];
  32.  
  33.                 if (command == "Change")
  34.                 {
  35.                     string letter = parts[1];
  36.                     string replacement = parts[2];
  37.                     text = text.Replace(letter, replacement);
  38.  
  39.                 }
  40.                 else if (command == "Uppercase")
  41.                 {
  42.                     text = text.ToUpper();
  43.                     Console.WriteLine(text);
  44.                 }
  45.                 else if (command == "Includes")
  46.                 {
  47.                     string newString = parts[1];
  48.                     if (text.Contains(newString))
  49.                     {
  50.                         Console.WriteLine("True");
  51.                     }
  52.                     else
  53.                     {
  54.                         Console.WriteLine("False");
  55.                     }    
  56.            
  57.                 }
  58.                 else if (command == "End")
  59.                 {
  60.                     string endString = parts[1];
  61.                     if (text.EndsWith(endString))
  62.                     {
  63.                         Console.WriteLine("True");
  64.                     }
  65.                     else
  66.                     {
  67.                         Console.WriteLine("False");
  68.                     }
  69.                 }
  70.                 else if (command == "FindIndex")
  71.                 {
  72.                     int index = text.IndexOf(parts[1]);
  73.                     Console.WriteLine(index);
  74.                 }
  75.                 else if (command == "Cut")
  76.                 {
  77.                     int startIdx = int.Parse(parts[1]);
  78.                     int lenght = int.Parse(parts[2]);
  79.                     text = text.Substring(startIdx, lenght);
  80.                     Console.WriteLine(text);
  81.                 }
  82.  
  83.  
  84.             }
  85.         }
  86.     }
  87. }
  88.  
Add Comment
Please, Sign In to add comment