-
Notifications
You must be signed in to change notification settings - Fork 0
Java05. ДЗ 01, Егоров Антон #1
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
Теперь должен работать mvn test
|
|
||
| p.isTerminal = true; | ||
| return true; | ||
| } |
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.
странное форматирование, табы/пробелы?
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 TrieImplTest | ||
| extends TestCase | ||
| { |
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.
форматирование выше
| assertEquals(0, b.howManyStartsWithPrefix("HeadZ")); | ||
|
|
||
| assertTrue(b.remove("Head")); | ||
| assertEquals(0, b.size()); |
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.
тесты стоит представлять в виде наименее возможных тестовых случаев, чтобы их можно было читать, понять, что проверено, а что нет
hw_01/src/main/java/hw_01/Bor.java
Outdated
| Node p = bor; | ||
| p.nwords++; | ||
| for (int i = 0; i < element.length(); i++) { | ||
| if (p.lifes[arr_num(element.charAt(i))] == 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.
arr_num(element.charAt(i)) используется три раза, что намекает на переменную
hw_01/src/main/java/hw_01/Bor.java
Outdated
| return true; | ||
| } | ||
|
|
||
| return false; |
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 p.isTerminal;
hw_01/src/main/java/hw_01/Bor.java
Outdated
| } | ||
|
|
||
| private Node bor; | ||
| private int size = 0; |
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.
почему не равен bor.nwords?
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.
Я думал, что size это количество символов в боре.
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.
нет, это количество строк в боре, что эквивалентно количеству терминальных узлов или же bor.nwords
hw_01/src/main/java/hw_01/Bor.java
Outdated
| } | ||
|
|
||
| private Node bor; | ||
| private int size = 0; |
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.
поля описываются в начале класса
hw_01/src/main/java/hw_01/Bor.java
Outdated
| return p.nwords; | ||
| } | ||
|
|
||
| private Node bor; |
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.
final
hw_01/src/main/java/hw_01/Bor.java
Outdated
|
|
||
| private Node bor; | ||
| private int size = 0; | ||
| private int arr_num(char a) { |
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.
в джаве CamelCase именование
Разделил тесты на блоки.
| return p.nwords; | ||
| } | ||
|
|
||
| private int arrNum(char a) { |
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.
на буквах экономить не стоит, особенно если они помогают понимать код, что верно почти всегда
| assertEquals(4, b.size()); | ||
| } | ||
| /* | ||
| public void testBorBigTest() { |
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.
ненужный код лучше удалять, чтобы он не мозолил глаза
в крайнем случае, он останется в истории системы контроля версий
| import junit.framework.TestCase; | ||
|
|
||
| public class TrieImplTest extends TestCase { | ||
| private Bor b; |
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.