output is seems correct
then why i get errors
package com.codegym.task.task15.task1504;
import java.util.LinkedList;
import java.util.List;
/*
OOP: Books
*/
public class Solution {
public static class MarkTwainBook extends Book{
String title;
public MarkTwainBook(String title) {
super("Mark Twain");
this.title = title;
}
public MarkTwainBook getBook(){
return (this);
}
public String getTitle(){
return title;
}
}
public static class AgathaChristieBook extends Book{
String title;
public AgathaChristieBook(String title ){
super("Agatha Christie");
this.title = title;
}
public AgathaChristieBook getBook(){
return this;
}
public String getTitle(){
return title;
}
}
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 = author + ": " + getBook().getTitle() + " is a detective";
String markTwainOutput = getBook().getTitle() + " was written by " + author;
String o = null ;
String output = getTitle();
{
if (output.equals("Tom Sawyer")){
o = markTwainOutput;
}
else if (output.equals("Hercule Poirot"))
{
o = agathaChristieOutput;
}
}
return o;
}
public String toString() {
return getOutputByBookType();
}
}
}