Skip to content

Homework 9 is done#6

Open
ushki92 wants to merge 2 commits into
masterfrom
lesson9
Open

Homework 9 is done#6
ushki92 wants to merge 2 commits into
masterfrom
lesson9

Conversation

@ushki92

@ushki92 ushki92 commented Sep 23, 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.

Нужны доработки

this.authorNameTwo = authorNameTwo;
this.authorNameThree = authorNameThree;
this.authorSurname = authorSurname;
this.authorFullName = authorName + " " + authorNameTwo + " " + authorNameThree + " " + authorSurname + " ";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

В таком случае нужно проверять, что все имена указаны.
Так как если одно из них будет null, в твоем fullName появится Ivanov null Ivanovich

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

У меня дальше идет замена 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?

Comment on lines +8 to +12
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.

А где геттеры?

Comment on lines +7 to +9
Author 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 + геттеры

Comment on lines +7 to +8
Author author;
String nameOfBook;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

final (отсутствуют сеттеры)

Comment on lines +7 to +9
Author 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.

А тут ещё и сеттер нужен.

Comment on lines +11 to +13
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.

Этот цикл лишний.
Книги и так при инициализации заполнены нуллами.

}
}

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.

Методы должны быть с маленькой буквы.

Comment on lines +27 to +35
System.out.println("Libryary:");
for (Book book : books) {
if (book != null) {
System.out.print(book.toString());
System.out.println();
} else {
break;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Никакого System.out.println
Метод toString обязан вернуть строковое представление объекта.
В консоль он печатать не должен.

Comment on lines +20 to +23
@Override
public String toString() {
return "Libryary" + System.lineSeparator() + books[0] + System.lineSeparator() + books[1];
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Вот тут не получилось.
Если книг будет больше придется все менять
А если вставляю цикл Java не дает из цикла вставить в 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.

Делаем стринг билдер, добавляем туда "Library:\n", а затем в цикле аппендим к билдеру книги.

@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.

Почти отлично.

this.authorNameTwo = authorNameTwo;
this.authorNameThree = authorNameThree;
this.authorSurname = authorSurname;
this.authorFullName = authorName + " " + authorNameTwo + " " + authorNameThree + " " + authorSurname + " ";

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?


private final Author author;
private final 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

private final String authorName;
private String authorNameTwo;
private String authorNameThree;
private String authorSurname;

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 +20 to +23
@Override
public String toString() {
return "Libryary" + System.lineSeparator() + books[0] + System.lineSeparator() + books[1];
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Делаем стринг билдер, добавляем туда "Library:\n", а затем в цикле аппендим к билдеру книги.

Comment on lines +12 to +17
for (int i = 0; i < books.length; i++) {
if (books[i] == null) {
books[i] = book;
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.

Ничего не выводит, если книга не была добавлена.

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