-
Notifications
You must be signed in to change notification settings - Fork 0
Hw4 unique list #8
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?
Conversation
| list.DeleteByIndex(2); | ||
| list.DeleteByIndex(7); | ||
| list.DeleteByIndex(1); | ||
| Assert.IsFalse(list.IsConsist(2) || list.IsConsist(8) || list.IsConsist(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.
Лучше разбить на отдельные Assert-ы, чтобы если что пойдёт не так, сразу знать, в чём дело
| [TestCase] | ||
| public void TestGetSize() | ||
| { | ||
| Assert.IsTrue(list.GetSize() == 8); |
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.
AreEqual лучше
hw4UniqueList/hw4UniqueList/List.cs
Outdated
| /// </summary> | ||
| public class List | ||
| { | ||
| private int Size { 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.
private-свойства вообще довольно бесполезны, поскольку находятся "внутри" инкапсуляции класса. Их можно заменить на поля всегда.
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.
Не поправлено
hw4UniqueList/hw4UniqueList/List.cs
Outdated
| Size = 0; | ||
| head = null; |
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.
Они и так null и 0, можно конструктор вообще не писать
hw4UniqueList/hw4UniqueList/List.cs
Outdated
|
|
||
| private Node head; | ||
|
|
||
| private Node runner; |
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 override int DeleteByIndex(int possition) | ||
| { | ||
| if (possition > GetSize() || possition < 1) | ||
| { | ||
| throw new IndexOutOfRangeException(); | ||
| } | ||
| return base.DeleteByIndex(possition); | ||
| } | ||
|
|
||
| public override void DeleteByValue(int value) | ||
| { | ||
| if (!IsConsist(value)) | ||
| { | ||
| throw new ValueDoesNotExistException("Такого значения в списке не существует!"); | ||
| } | ||
| base.DeleteByValue(value); | ||
| } |
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 (possition > GetSize() || possition < 1) | ||
| { | ||
| throw new IndexOutOfRangeException(); | ||
| } |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| } | ||
| else if (IsConsist(value)) | ||
| { | ||
| throw new ValueIsAlreadyInListException("Такое значение уже есть в списке!"); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| namespace hw4UniqueList | ||
| { | ||
| public class ValueDoesNotExistException : Exception |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| namespace hw4UniqueList | ||
| { | ||
| public class ValueIsAlreadyInListException : Exception |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Надо доисправлять
| list.DeleteByValue(2); | ||
| list.DeleteByValue(8); | ||
| list.DeleteByValue(1); | ||
| Assert.IsFalse(list.Contains(2) || list.Contains(8) || list.Contains(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.
Где-то разбили на ассерты, а тут нет
| [TestCase] | ||
| public void TestGetSize() | ||
| { | ||
| Assert.AreEqual(list.GetSize(), 8); |
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.
Наоборот, сначала ожидаемое значение, потом то, что получилось. Иначе сообщения об ошибках будут неправильными
hw4UniqueList/hw4UniqueList/List.cs
Outdated
| /// </summary> | ||
| public class List | ||
| { | ||
| private int Size { 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.
Не поправлено
| base.DeleteByValue(value); | ||
| } | ||
|
|
||
| public override void ChangeByIndex(int possition, int value) |
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.
position
| public override int DeleteByIndex(int possition) | ||
| { | ||
| return base.DeleteByIndex(possition); | ||
| } |
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.
Если потомок ничего не добавляет, то переопределение и не нужно. Если потомок не переопределяет виртуальный метод предка, то будет сразу метод предка вызываться.
| using NUnit.Framework; | ||
| using System; | ||
|
|
||
| namespace hw4UniqueList.Test |
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.
Нэймспейсы бы ещё с заглавной...
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.
Ага, зачтена
No description provided.