From 47887307ab3591817141178f84a905234c3d52bf Mon Sep 17 00:00:00 2001 From: esoe Date: Fri, 14 Oct 2022 18:24:11 +0300 Subject: [PATCH] qq --- book/src/main/java/ru/molokoin/Book.java | 25 +++++++++++++++++---- book/target/classes/ru/molokoin/Book.class | Bin 2181 -> 2670 bytes 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/book/src/main/java/ru/molokoin/Book.java b/book/src/main/java/ru/molokoin/Book.java index 7f80871..887a1b4 100644 --- a/book/src/main/java/ru/molokoin/Book.java +++ b/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 author, Object year, Object publisher){ this(name, year, publisher); - //TODO authorsUppend(author){не забыть создать новый массив, если его небыло} - String[] authors = new String[1]; - authors[0] = (String) author; - setAuthors(authors); + setAuthors(uppendAuthors((String)author)); } Book(Object name, Object[] authors, Object year, Object publisher){ this(name, year, publisher); String[] a = (String[]) authors; 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){ String author = getAuthors()[index]; return author; diff --git a/book/target/classes/ru/molokoin/Book.class b/book/target/classes/ru/molokoin/Book.class index 238bccb7332b7b2db91f328b7ffd38c6c9012145..689b20bb895c26209b92cb1e475262073236919c 100644 GIT binary patch literal 2670 zcmbVN-BMds7+pKRBpm+I2Bax1)M`Tr39V2oP_)pZKuFOb%IJk5oPm^(Fd=c;3um-C zQqC7Q zCKLiY)wM!?cT+Db^rRXQmrgEd<$0uMX`tp5{Ml+{vsB(yIQNMYpl>o?%vYuq+|j`m zdd`&A^&s5n($I!>g^pCdsHdyjYk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