Skip to content

Homework 8 is done#5

Open
ushki92 wants to merge 1 commit into
masterfrom
lesson8
Open

Homework 8 is done#5
ushki92 wants to merge 1 commit into
masterfrom
lesson8

Conversation

@ushki92

@ushki92 ushki92 commented Sep 22, 2021

Copy link
Copy Markdown
Owner

No description provided.

@DisterDE DisterDE left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

В целом хорошо, но нужны доработки.

Comment on lines +4 to +8
private String authorName;
private String authorNameTwo;
private String authorNameThree;
private String authorSurname;
private String authorFullName;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Такое количество имен, конечно, поражает. :)
Так же следует убрать из имен полей слово author, так как и так понятно, кому они принадлежат.

}

public String getAuthorFullName() {
authorFullName = authorFullName.replace("null ", "");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Чтобы этого не было, нужно собирать fullName через StringBuilder, проверяя каждое поле на null.

Comment on lines +13 to +15
public Book() {

}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Этот конструктор тут не нужен.
Книга не может быть создана без названия и автора.

Comment on lines +4 to +6
String author;
String nameOfBook;
int dateOfPublish;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Поля должны быть private, а в случае отсутствия сеттера, ещё и final

Comment on lines +4 to +6
String author;
String nameOfBook;
int dateOfPublish;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Это скорее yearOfPublish.

for (int i = 0; i < books.length; i++) {
if (books[i] == null) {
books[i] = book;
System.out.println();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

А зачем тут что-то печатать?

Comment on lines +9 to +11
for (int i = 0; i < books.length; i++) {
books[i] = null;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Массив books при создании и так заполнился нуллами.
Этот цикл ничего не делает.

}
}

public void AddNewBook(Book book) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Методы в java принято называть с маленькой буквы.

}
}

public void PrintAllBooks() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Методы в java принято называть с маленькой буквы.

Comment on lines +31 to +33
} else {
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно поменять местами условие и это поможет избавиться от else блока.

if (books[i] == null) {
    return;
}

Тут уже печатаем.

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.

2 participants