-
Notifications
You must be signed in to change notification settings - Fork 0
test #6
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?
test #6
Conversation
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.
Очень топорно и неаккуратно, но в целом так. Кстати, Dictionary бы лучше подошёл для хранения элементов вектора.
| namespace Test1._1Task1 | ||
| { | ||
|
|
||
| public class Vectors |
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.
Надо больше комментариев
|
|
||
| public class Vectors | ||
| { | ||
| public Dictionary<int, Vectors> VectorsDictionary { get; set; } |
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.
Словарь, который отображает число в Vectors, это типа дерево векторов? Что? :)
| VectorsDictionary.Add(index, vector); | ||
| } | ||
|
|
||
| public (int index, int number)[] Vector { get; set; } |
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.
Вообще, плохая идея предоставлять public-сеттеры ко всему, чему можно, это нарушает инкапсуляцию
| VectorsDictionary.Add(index, vector); | ||
| } | ||
|
|
||
| public void delete(Vectors vector, int index) |
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.
Методы в C# всегда именуются с заглавной
|
|
||
| public void delete(Vectors vector, int index) | ||
| { | ||
| VectorsDictionary.Add(index, vector); |
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.
Неправда :)
| /// сложение векторов | ||
| /// </summary> | ||
| /// <returns>вернет вектор сложения</returns> | ||
| public (int index, int number)[] Addition(Vectors vector1, Vectors vector2) |
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 (!CheckSize(vector1.Size, vector2.Size)) | ||
| { | ||
| //throw 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.
А почему нет? :)
| } | ||
| } | ||
| return vector; | ||
| } |
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.
Копипастище :) Можно было просто инвертировать знаки и сложить
| vector[3] = (5, 1); | ||
| vector[4] = (6, 1); | ||
| vector[5] = (9, 2); | ||
| Assert.IsTrue(vector == vector1.Addition(vector1, vector2)); |
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.
Не-а, это будет ссылочное равенство. Assert.AreEqual бы помог, он сравнивает массивы поэлементно
No description provided.