radidim

P03 (C# Shell App Paste)

May 23rd, 2020
1,487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. namespace CSharp_Shell
  8. {
  9.  
  10.     public static class Program
  11.     {
  12.        
  13.         public static void Main()
  14.         {
  15.            var journal = Console.ReadLine().Split(new []{',',' '},StringSplitOptions.RemoveEmptyEntries).ToArray();
  16.            
  17.                        
  18.            while(true)
  19.            {
  20.             var input = Console.ReadLine().ToLower();
  21.            
  22.             if(input == "exit")
  23.             {
  24.                 break;
  25.             }
  26.            
  27.             var commands = input.Split(" - ");
  28.             string command = commands[0];
  29.             string item = commands[1];
  30.            
  31.             if(command =="collect")
  32.             {
  33.                 var newJournal = new string[journal.Length+1];
  34.                
  35.                 for(int i=0;i<journal.Length;i++)
  36.                 {
  37.                    
  38.                    
  39.                     if(item == journal[i])
  40.                     {
  41.                         break;
  42.                     }
  43.                     newJournal[i]=journal[i];
  44.                 }
  45.                 newJournal[newJournal.Length-1]=item;
  46.                 journal=newJournal;
  47.             }
  48.            
  49.             if(command == "drop")
  50.             {
  51.                
  52.                 var newJournal = new string[journal.Length-1];
  53.                 for(int i=0;i<journal.Length;i++)
  54.                 {
  55.                    
  56.                     if(item == journal[i])
  57.                     {
  58.                         break;
  59.                     }
  60.                     newJournal[i]=journal[i];
  61.                 }
  62.                 journal=newJournal;
  63.             }
  64.            
  65.             if(command=="combine")
  66.             {
  67.                
  68.             }
  69.            
  70.             if(command=="renew")
  71.             {
  72.                
  73.             }
  74.            
  75.            }
  76.            for(int  i=0;i<journal.Length-1;i++)
  77.            {
  78.             Console.Write(journal[i] + ", ");
  79.            
  80.            }
  81.             Console.Write(journal[journal.Length-1]);
  82.             Console.WriteLine(" ");
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment