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 = author + ": " + getBook().getTitle() + " is a detective";
            String markTwainOutput = getBook().getTitle() + " was written by " + author;

            String output = getTitle();
            if (getTitle().equals("Hercule Poirot")){
                return agathaChristieOutput;
            } else {
                return markTwainOutput;
            }
        }
        public String toString() {
            return getOutputByBookType();
        }
    }
    public static class MarkTwainBook extends Book {
        private String title;
        public MarkTwainBook(String title){
            super("Mark Twain");
            this.title = title;

        }
        @Override
        public MarkTwainBook getBook() {
            return  this;
        }
        @Override
        public String getTitle() {
            return this.title;
        }
    }
    public static class AgathaChristieBook extends Book {
        private String title;
        public AgathaChristieBook(String title){
            super("Agatha Christie");
            this.title = title;
        }
        @Override
        public AgathaChristieBook getBook() {
            return this;
        }
        @Override
        public String getTitle() {
            return this.title;
        }
    }

}
This returns an error "The getOutputByBookType method must return the correct string for AgathaChristieBook objects." When testing the code in Intellij it seems to be all okay and compliant with the given parameters? Thanks :)!