-
Notifications
You must be signed in to change notification settings - Fork 0
Hw5 routers #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Hw5 routers #9
Conversation
| {0, 0, 0, 9 }, | ||
| {3, 6, 9, 0 } | ||
| }; | ||
| Assert.AreEqual(AlgorithmPrima.Algorithm(graphSecond), graphSecondResult); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
hw5Routers/hw5Routers/Program.cs
Outdated
| { | ||
| try | ||
| { | ||
| FileFunctions.WriteInFile(AlgorithmPrima.Algorithm(FileFunctions.CreateGraph("..\\..\\..\\Routers2.txt")), "RoutersTestResult.txt"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По условию, Пути до входного и выходного файлов должны приниматься в качестве параметров.
hw5Routers/hw5Routers/Program.cs
Outdated
| { | ||
| Console.Error.WriteLine("Граф несвязный!"); | ||
| } | ||
| //Routers.WriteInFile(AlgorithmPrima.Algorithm(Routers.CreateGraph(args[0])), args[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А вот закомментированный код не нужен
|
|
||
| namespace hw5Routers | ||
| { | ||
| public class GraphDisconnectedException : Exception |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| using System.Collections.Generic; | ||
| using System.Text; | ||
|
|
||
| namespace hw5Routers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Пространство имён должно называться с заглавной
| { | ||
| stringLine = stringLine.Replace(':', ' '); | ||
| stringLine = stringLine.Replace(',', ' '); | ||
| string[] lineDrop = stringLine.Split(" ", StringSplitOptions.RemoveEmptyEntries); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split может принимать сразу массив символов, по которым разбивать строку, что позволяет не делать Replace-ы
|
|
||
| private static int CountsVertexs(string path) | ||
| { | ||
| var file = new StreamReader(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var file = new StreamReader(path); | |
| using var file = new StreamReader(path); |
| return matrix; | ||
| } | ||
|
|
||
| private static int CountsVertexs(string path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private static int CountsVertexs(string path) | |
| private static int CountVertexes(string path) |
| /// </summary> | ||
| public static void WriteInFile(int[,] matrix, string filePath) | ||
| { | ||
| FileInfo fileOut = new FileInfo(filePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| FileInfo fileOut = new FileInfo(filePath); | |
| var fileOut = new FileInfo(filePath); |
| { | ||
| fileOut.Delete(); | ||
| } | ||
| FileStream newFile = new FileStream(filePath, FileMode.Create); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| FileStream newFile = new FileStream(filePath, FileMode.Create); | |
| using var newFile = new FileStream(filePath, FileMode.Create); |
yurii-litvinov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почти всё ок, но пока не совсем ок.
| isConsist[indexFirst] = true; | ||
| for (int indexSecond = 0; indexSecond < size; indexSecond++) | ||
| { | ||
| if (matrix[indexFirst, indexSecond] != 0 && isConsist[indexSecond] == false && matrix[indexFirst, indexSecond] > key[indexSecond]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (matrix[indexFirst, indexSecond] != 0 && isConsist[indexSecond] == false && matrix[indexFirst, indexSecond] > key[indexSecond]) | |
| if (matrix[indexFirst, indexSecond] != 0 && !isConsist[indexSecond] && matrix[indexFirst, indexSecond] > key[indexSecond]) |
|
|
||
| namespace Hw5Routers | ||
| { | ||
| public static class FileFunctions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И даже этому классу надо комментарий :)
| { | ||
| var numberSecond = Int32.Parse(lineDrop[i]) - 1; | ||
| var distance = Int32.Parse(lineDrop[i + 1].Substring(1, lineDrop[i + 1].Length - 2)); | ||
| matrix[numberFirst, numberSecond] = matrix[numberSecond, numberFirst] = distance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше всё-таки это двумя отдельными операциями делать
| fileOut.Delete(); | ||
| } | ||
| using var newFile = new FileStream(filePath, FileMode.Create); | ||
| StreamWriter file = new StreamWriter(newFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var
| { | ||
| try | ||
| { | ||
| FileFunctions.WriteInFile(AlgorithmPrima.Algorithm(FileFunctions.CreateGraph(args[0])), args[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это если предположить, что нам реально передали два параметра. А скорее всего, первый раз программу вообще без параметров запустят, потому что привыкли, что в этом случае она распечатает подсказку по использованию (так делают все нормальные консольные утилиты, кому нужны параметры для работы).
|
|
||
| namespace Hw5Routers | ||
| { | ||
| public class NoParametersException : Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вы не поверите, ему тоже нужны комментарии
| { | ||
| Console.Error.WriteLine("Граф несвязный!"); | ||
| } | ||
| catch (NoParametersException) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Оно не так работает. Проверяли, что будет, если без параметров запустить?
No description provided.