You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.4 KiB

2 years ago
package ru.molokoin;
public class Book {
private String name;
private Publisher publisher;
private int year;
private String[] authors;
2 years ago
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);
}
Book(Object name, Object[] authors, Object year, Object publisher){
this(name, year, publisher);
String[] a = (String[]) authors;
setAuthors(a);
}
2 years ago
public String getAuthorByIndex(int index){
String author = getAuthors()[index];
return author;
}
//количество авторов книги
public int getAuthorsCount(){
//TODO проверить наличие массива - null
return getAuthors().length;
}
/**
* @param name the name to set
*/
public void setName(String name) {
2 years ago
//TODO название книги не должно быть пустой ссылкой;
2 years ago
this.name = name;
}
/**
* @param publisher the publisher to set
*/
public void setPublisher(Publisher publisher) {
2 years ago
//TODO издательство не должно быть пустой ссылкой;
2 years ago
this.publisher = publisher;
}
/**
* @param year the year to set
*/
public void setYear(int year) {
2 years ago
//TODO год издания должен быть строго больше нуля
2 years ago
this.year = year;
}
/**
* @param author the author to set
*/
public void setAuthors(String[] authors) {
2 years ago
//TODO массив не должен содержать пустых ссылок
2 years ago
this.authors = authors;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the publisher
*/
public Publisher getPublisher() {
return publisher;
}
/**
* @return the year
*/
public int getYear() {
return year;
}
/**
* @return the author
*/
public String[] getAuthors() {
return authors;
}
}