Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a 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
Copy link
Collaborator

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; }
Copy link
Collaborator

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; }
Copy link
Collaborator

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)
Copy link
Collaborator

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);
Copy link
Collaborator

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)
Copy link
Collaborator

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему нет? :)

}
}
return vector;
}
Copy link
Collaborator

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));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не-а, это будет ссылочное равенство. Assert.AreEqual бы помог, он сравнивает массивы поэлементно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants