Esempio n. 1
0
        public static void Main()
        {
            Console.WriteLine(@"Please, enter ""help"" to recieve information about the commands available. 
    ALL COMMANDS are lowercase only! 
    See for examples in ""help"" section.");
            Console.WriteLine();

            IContentComparer  tester    = new Tester();
            IDirectoryManager ioManager = new IOManager();
            IDatabase         repo      = new StudentsRepository(new RepositorySorter(), new RepositoryFilter());

            IInterpreter currentInterpreter = new CommandInterpreter(tester, repo, ioManager);
            IReader      reader             = new InputReader(currentInterpreter);

            reader.StartReadingCommands();
        }
Esempio n. 2
0
 private static void TryShowWantedData(List <string> commandParameters, string command)
 {
     if (commandParameters.Count() == 1)
     {
         string courseName = commandParameters[0];
         StudentsRepository.GetAllStudentsFromCourse(courseName);
     }
     else if (commandParameters.Count() == 2)
     {
         string courseName = commandParameters[0];
         string userName   = commandParameters[1];
         StudentsRepository.GetStudentScoresFromCourse(courseName, userName);
     }
     else
     {
         OutputWriter.DisplayException(command, ExceptionMessages.InvalidCommand);
     }
 }
Esempio n. 3
0
 private static void TryShowWantedData(string input, string[] data)
 {
     if (data.Length == 2)
     {
         string courseName = data[1];
         StudentsRepository.GetAllStudentsFromCourse(courseName);
     }
     else if (data.Length == 3)
     {
         string courseName = data[1];
         string userName   = data[2];
         StudentsRepository.GetStudentScoresFromCourse(courseName, userName);
     }
     else
     {
         DisplayInvalidCommandMessage(input);
     }
 }
Esempio n. 4
0
        private void FilterAndTake(Dictionary <string, double> sudentsWithMarks, Predicate <double> givenFilter, int studentsToTake)
        {
            int counterForPrinted = 0;

            foreach (var userName_Points in sudentsWithMarks)
            {
                if (counterForPrinted == studentsToTake)
                {
                    break;
                }

                if (givenFilter(userName_Points.Value))
                {
                    StudentsRepository studentsRepository = new StudentsRepository(new RepositoryFilter(), new RepositorySorters());
                    studentsRepository.PrintStudent(userName_Points);
                    counterForPrinted++;
                }
            }
        }
        public static void Main()
        {
            #region comments
            // These comments below are some tests that I used to use from C# Advanced course

            /* P1 Tests
             * IOManager.TraverseDirectory(@"D:\Downloads");
             *
             * P2 Tests
             * StudentsRepository.InitializeData();
             * StudentsRepository.GetAllStudentsByCourse("Unity");
             * StudentsRepository.GetStudentMarkInCourse("Unity", "Ivan");
             *
             * P3 Tests
             * Tester.CompareContent(@".\BashSoft-Resources\test1.txt", @".\BashSoft-Resources\test2.txt");
             * Tester.CompareContent(@".\BashSoft-Resources\test1.txt", @".\BashSoft-Resources\test3.txt");
             *
             * P4 Tests
             * IOManager.CreateDirectoryInCurrentFolder("Pesho");
             * IOManager.TraverseDirectory(5);
             * IOManager.CreateDirectoryInCurrentFolder("Pesho");
             * IOManager.ChangeCurrentDirectoryRelative("Pesho");
             * IOManager.ChangeCurrentDirectoryAbsolute("Pesho");
             * IOManager.ChangeCurrentDirectoryAbsolute(@"C:\Windows");
             * IOManager.TraverseDirectory(20);
             * Tester.CompareContent("actual", "expecter");
             * IOManager.CreateDirectoryInCurrentFolder("*2");
             *
             * InputReader.StartReadingCommands(); */
            #endregion

            IContentComparer  tester    = new Tester();
            IDirectoryManager ioManager = new IOManager();
            IDatabase         repo      = new StudentsRepository(new RepositoryFilters(), new RepositorySorters());

            IInterpreter currentInterpreter = new CommandInterpreter(tester, repo, ioManager);
            IReader      reader             = new InputReader(currentInterpreter);

            reader.StartReadingCommands();
        }
 private static void TryParseParametersForOrderAndTake(string takeCommand, string takeQuantity, string course, string filter)
 {
     if (takeCommand == "take")
     {
         if (takeQuantity == "all")
         {
             StudentsRepository.OrderAndTake(course, filter);
         }
         else
         {
             int  studentsToTake;
             bool hasParsed = int.TryParse(takeQuantity, out studentsToTake);
             if (hasParsed)
             {
                 StudentsRepository.OrderAndTake(course, filter, studentsToTake);
             }
             else
             {
                 OutputWriter.DisplayException(ExceptionMessages.InvalidTakeQuantityParameter);
             }
         }
     }
 }
Esempio n. 7
0
        public static void Main()
        {
            //IOManager.TraverseDirectory(10);

            //StudentsRepository.InitializeData();
            //StudentsRepository.GetAllStudentFromCourse("Unity");
            //StudentsRepository.GetStudentScoresFromCourse("Unity", "Ivan");

            //Tester.CompareContent(@"C:\Users\vradoyko\Desktop\user\test2.txt", @"C:\Users\vradoyko\Desktop\user\test3.txt");

            //IOManager.CreateDirectoryInCurrentFolder("vasko");
            //IOManager.ChangeCurrentDirectoryAbsolute(@"C:\windows");
            //IOManager.ChangeCurrentDirectoryRelative("..");
            //IOManager.TraverseDirectory(50);

            IContentComparer  tester    = new Tester();
            IDirectoryManager ioManager = new IOManager();
            IDatabase         repo      = new StudentsRepository(new RepositoryFilter(), new RepositorySorter());

            IInterpreter cmdInterpreter = new CommandInterpreter(tester, repo, ioManager);
            IReader      reader         = new InputReader(cmdInterpreter);

            reader.StartReadingCommands();
        }
Esempio n. 8
0
        private static void TryShowWantedData(string input, string[] data)
        {
            switch (data.Length)
            {
            case 2:
            {
                string courseName = data[1];
                StudentsRepository.GetAllStudentsFromCourse(courseName);
            }
            break;

            case 3:
            {
                string courseName = data[1];
                string username   = data[2];
                StudentsRepository.GetStudentScoresFromCourse(courseName, username);
            }
            break;

            default:
                OutputWriter.DisplayException(string.Format(ExceptionMessages.InvalidCommandParametersCount, data[0]));
                break;
            }
        }
 public ShowCourseCommand(string input, string[] data, Tester judge, StudentsRepository repository, IOManager inputOutputManager) : base(input, data, judge, repository, inputOutputManager)
 {
 }
 public CommandInterpreter(Tester judge, StudentsRepository repository, IOManager inputOutputManager)
 {
     this.judge              = judge;
     this.repository         = repository;
     this.inputOutputManager = inputOutputManager;
 }
        private static void TryReadDatabaseFromFile(string input, string[] data)
        {
            string fileName = data[1];

            StudentsRepository.InitializedData(fileName);
        }
Esempio n. 12
0
        public static void Main(string[] args)
        {
            #region AdvancedTests
            ///
            ///Testing Traversing A Folder
            ///Works
            ///
            //IOManager.TraverseDirectory();

            ///
            ///Testing Get All Students
            ///Works kinda
            ///
            //StudentsRepository.InitializeData();
            //StudentsRepository.GetAllStudentsFromCourse("Unity");
            //StudentsRepository.GetStudentScoresFromCourse("Unity", "Ivan");

            ///
            ///Testing Comparing Files
            ///Works
            ///
            //Tester.CompareContent(@"E:\Projects\BashSoft\BashSoft\BashSoft\resources\test2.txt"
            //                    , @"E:\Projects\BashSoft\BashSoft\BashSoft\resources\test3.txt");

            // cmp E:\Projects\BashSoft\BashSoft\BashSoft\resources\test1.txt E:\Projects\BashSoft\BashSoft\BashSoft\resources\test2.txt

            ///
            ///Testing Creating Folders And Traversing Folders
            ///Works
            ///
            //IOManager.CreateDirectoryInCurrentFolder("*2");
            //IOManager.ChangeCurrentDirectoryAbsolute(@"C:\Windows");
            //IOManager.TraverseDirectory(20);

            ///
            ///Testing Going one folder up the hierarchy
            ///Works
            ///
            //IOManager.ChangeCurrentDirectoryRelative("..");
            //IOManager.ChangeCurrentDirectoryRelative("..");
            //IOManager.ChangeCurrentDirectoryRelative("..");
            //IOManager.ChangeCurrentDirectoryRelative("..");
            //IOManager.ChangeCurrentDirectoryRelative("..");
            //IOManager.ChangeCurrentDirectoryRelative("..");
            //IOManager.ChangeCurrentDirectoryRelative("..");

            ///
            ///Testing InputReader and CommandInterpreter
            ///Works
            ///
            #endregion

            IContentComparer  tester    = new Tester();
            IDirectoryManager ioManager = new IOManager();
            IDatabase         repo      = new StudentsRepository(new RepositoryFilter(), new RepositorySorter());

            IInterpreter currentInterpreter = new CommandInterpreter(tester, repo, ioManager);
            IReader      reader             = new InputReader(currentInterpreter);

            reader.StartReadingCommands();

            ///
            ///Tips
            ///use cdrel resources
            ///then read files from there with readdb
            ///or help to see other commands
            ///
        }
Esempio n. 13
0
 public ChangePathAbsoluteCommand(string input, string[] data, Tester judge, StudentsRepository repository, IOManager inputOutputManager) : base(input, data, judge, repository, inputOutputManager)
 {
 }
 public PrintFilteredStudentsCommand(string input, string[] data, Tester judge, StudentsRepository repository, IOManager inputOutputManager) : base(input, data, judge, repository, inputOutputManager)
 {
 }
 public DownloadRequestCommand(string input, string[] data, Tester judge, StudentsRepository repository, IOManager inputOutputManager) : base(input, data, judge, repository, inputOutputManager)
 {
 }
Esempio n. 16
0
 public TraverseFoldersCommand(string input, string[] data, Tester judge, StudentsRepository repository, IOManager inputOutputManager) : base(input, data, judge, repository, inputOutputManager)
 {
 }
Esempio n. 17
0
        public static void InterpredCommand(string input)
        {
            string[] data              = input.Split(' ');
            string   command           = data[0];
            int      indexOfFirstSpace = input.IndexOf(' ');
            string   inputAfterCommand = input.Substring(indexOfFirstSpace + 1);

            switch (command)
            {
            case "mkdir":
                if (data.Length == 2)
                {
                    IOManager.CreateDirectoryInCurrentFolder(data[1]);
                }
                else
                {
                    OutputWriter.DisplayException(ExceptionMessages.InvalidCommandParams);
                }
                break;

            case "ls":
                if (data.Length == 1)
                {
                    IOManager.ShowDirectory();
                }
                else
                {
                    OutputWriter.DisplayException(command + ExceptionMessages.UnNeededParameters);
                }
                break;

            case "clear":
                if (data.Length == 1)
                {
                    Console.Clear();
                }
                else
                {
                    OutputWriter.DisplayException(command + ExceptionMessages.UnNeededParameters);
                }
                break;

            case "cd":
                if (data.Length >= 2)
                {
                    IOManager.ChangeCurrentDirectoryRelative(inputAfterCommand);
                }
                else
                {
                    OutputWriter.DisplayException(command + ExceptionMessages.InvalidCommandParams);
                }
                break;

            case "readDb":
                StudentsRepository.InitializeData(inputAfterCommand);
                break;

            case "filter":
                if (data.Length == 2)
                {
                    StudentsRepository.GetAllStudentsFromCourse(data[1]);
                }
                break;

            case "download":
                if (data.Length > 1)
                {
                    IOManager.DownloadFile(inputAfterCommand);
                }
                else
                {
                    OutputWriter.DisplayException(ExceptionMessages.MissingURL);
                }
                break;

            case "open":
                if (data.Length == 2)
                {
                    IOManager.OpenFile(data[1]);
                }
                else
                {
                    OutputWriter.DisplayException(ExceptionMessages.MissingURL);
                }
                break;

            case "help":
                if (data.Length == 1)
                {
                    IOManager.Help();
                }
                else
                {
                    OutputWriter.DisplayException(command + ExceptionMessages.UnNeededParameters);
                }
                break;

            case "s":
                if (data.Length == 2)
                {
                    PremiumMobileRepository.SummarizeEmails(data[1]);
                }
                break;

            default:
                OutputWriter.DisplayException(ExceptionMessages.InvalidCommand);
                break;
            }
        }
Esempio n. 18
0
        private static void ReadDatabaseFromFile(List <string> commandParameters)
        {
            string fileName = commandParameters[0];

            StudentsRepository.InitializeData(fileName);
        }