esoe 2 years ago
parent
commit
47887307ab
  1. 25
      book/src/main/java/ru/molokoin/Book.java
  2. BIN
      book/target/classes/ru/molokoin/Book.class

25
book/src/main/java/ru/molokoin/Book.java

@ -9,16 +9,33 @@ public class Book {
Book(Object name, Object year, Object publisher){} Book(Object name, Object year, Object publisher){}
Book(Object name, Object author, Object year, Object publisher){ Book(Object name, Object author, Object year, Object publisher){
this(name, year, publisher); this(name, year, publisher);
//TODO authorsUppend(author){не забыть создать новый массив, если его небыло} setAuthors(uppendAuthors((String)author));
String[] authors = new String[1];
authors[0] = (String) author;
setAuthors(authors);
} }
Book(Object name, Object[] authors, Object year, Object publisher){ Book(Object name, Object[] authors, Object year, Object publisher){
this(name, year, publisher); this(name, year, publisher);
String[] a = (String[]) authors; String[] a = (String[]) authors;
setAuthors(a); setAuthors(a);
} }
public String[] uppendAuthors(String author){
String[] result;
try {
if (getAuthors() == null)throw new NullPointerException("Перечень авторов пока пуст ...");
} catch (NullPointerException e) {
e.printStackTrace();
result = new String[1];
result[0] = author;
return result;
}
result = new String[getAuthorsCount() + 1];
int i = 0;
while (i < getAuthorsCount()){
result[i] = getAuthorByIndex(i);
i++;
}
result[getAuthorsCount()] = author;
return result;
}
public String getAuthorByIndex(int index){ public String getAuthorByIndex(int index){
String author = getAuthors()[index]; String author = getAuthors()[index];
return author; return author;

BIN
book/target/classes/ru/molokoin/Book.class

Binary file not shown.
Loading…
Cancel
Save