Everything works...I don't know what codegym wants from me...I'm confused..
package com.codegym.task.task15.task1504;
import java.util.LinkedList;
import java.util.List;
/*
OOP: Books
*/
public class Solution {
public static void main(String[] args) {
List<Book> books = new LinkedList<Book>();
books.add(new MarkTwainBook("Tom Sawyer"));
books.add(new AgathaChristieBook("Hercule Poirot"));
System.out.println(books);
}
abstract static class Book {
private String author;
public Book(String author) {
this.author = author;
}
public abstract Book getBook();
public abstract String getTitle();
private String getOutputByBookType() {
String agathaChristieOutput = MarkTwainBook.author + ": " + getBook().getTitle() + " is a detective";
String markTwainOutput = getBook().getTitle() + " was written by " + AgathaChristieBook.author;
String output = "output";
if(getTitle().equals(MarkTwainBook.title)){
output = markTwainOutput;
} else if (getTitle().equals(AgathaChristieBook.title)){
output = agathaChristieOutput;
}
return output;
}
public String toString() {
return getOutputByBookType();
}
}
public static class MarkTwainBook extends Book{
public static String author = "Mark Twain";
public static String title;
public MarkTwainBook(String title){
super(title);
this.title = title;
}
public MarkTwainBook getBook(){
return this;
}
public String getTitle(){
return MarkTwainBook.title;
}
}
public static class AgathaChristieBook extends Book{
public static String author = "Agatha Christie";
public static String title;
public AgathaChristieBook(String title){
super(title);
AgathaChristieBook.title = title;
}
public AgathaChristieBook getBook(){
return this;
}
public String getTitle(){
return AgathaChristieBook.title;
}
}
}