Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- var journal = Console.ReadLine().Split(new []{',',' '},StringSplitOptions.RemoveEmptyEntries).ToArray();
- while(true)
- {
- var input = Console.ReadLine().ToLower();
- if(input == "exit")
- {
- break;
- }
- var commands = input.Split(" - ");
- string command = commands[0];
- if(command =="collect")
- {
- string item = commands[1];
- var newJournal = new string[journal.Length+1];
- for(int i=0;i<journal.Length;i++)
- {
- if(item == journal[i])
- {
- break;
- }
- newJournal[i]=journal[i];
- }
- newJournal[newJournal.Length-1]=item;
- journal=newJournal;
- }
- if(command == "drop")
- {
- string item = commands[1];
- var newJournal = new string[journal.Length-1];
- for(int i=0;i<journal.Length-1;i++)
- {
- if(item != journal[i])
- {
- newJournal[i]=journal[i];
- }
- else
- {
- newJournal[i]=journal[i+1];
- }
- }
- journal=newJournal;
- }
- if(command=="combine items")
- {
- var items = commands[1].Split(':');
- var oldItem = items[0];
- var newItem = items[1];
- Console.WriteLine(oldItem);
- Console.WriteLine(newItem);
- }
- if(command=="renew")
- {
- string item = commands[1];
- }
- }
- for(int i=0;i<journal.Length-1;i++)
- {
- Console.Write(journal[i] + ", ");
- }
- Console.Write(journal[journal.Length-1]);
- Console.WriteLine(" ");
- }
- public static T[] RemoveAt<T>(this T[] source, int index)
- {
- T[] dest = new T[source.Length - 1];
- if( index > 0 )
- Array.Copy(source, 0, dest, 0, index);
- if( index < source.Length - 1 )
- Array.Copy(source, index + 1, dest, index, source.Length - index - 1);
- return dest;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement