library having two types of books I need to make a project related to a library catalog.

It should have following methods relevant to these books:

add
delete
list
There are two types of books: novels and poetry. Both types have number of pages and names. Novels have categories (SF...) and poetry have themes. Need to be able to list the books in the library.

How should I model the code for this (using inheritance, Lists, no hashmap)? I have thought to create a class BasicBook (fields pages, names), Novels (field category) and Poetry (field theme) to inherit from BasicBook. Create a class Library (fields List Novel, List Poetry) and methods to add, delete, print).
Is there a better way to tackle this problem? Thanks a lot!

package com.andy85;  
public class Book {
private String name;
private int numOfPages;

  public Book(String name, int numOfPages) {
        this.name = name;
        this.numOfPages = numOfPages;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNumOfPages() {
        return numOfPages;
    }

    public void setNumOfPages(int numOfPages) {
        this.numOfPages = numOfPages;
    }

    @Override
    public String toString() {
        return this.name + ", " + this.numOfPages;
    }
}

public class Novel extends Book {
    private String types;

    public Novel(String name, int numOfPages, String types) {
        super(name, numOfPages);
        this.types = types;
    }

    public String getTypes() {
        return types;
    }

    public void setTypes(String types) {
        this.types = types;
    }

    @Override
    public String toString() {
        return super.toString() + ": " + types;
    }
}

public class ArtAlbum extends Book {
    private String paperQuality;

    public ArtAlbum(String name, int numOfPages, String paperQuality) {
        super(name, numOfPages);
        this.paperQuality = paperQuality;
    }

    public String getPaperQuality() {
        return paperQuality;
    }

    public void setPaperQuality(String paperQuality) {
        this.paperQuality = paperQuality;
    }

    @Override
    public String toString() {
        return super.toString() + paperQuality;
    }

public class LibraryCatalog {
    private List&lt;Novel&gt; novel = new ArrayList&lt;&gt;();
    private List&lt;ArtAlbum&gt; artAlbum = new ArrayList&lt;&gt;();

    public LibraryCatalog(List&lt;Novel&gt; novel, List&lt;ArtAlbum&gt; artAlbum) {
        this.novel = new ArrayList&lt;&gt;(novel);
        this.artAlbum = new ArrayList&lt;&gt;(artAlbum);
    }

    public List&lt;Novel&gt; getNovel() {
        return novel;
    }

    public void setNovel(List&lt;Novel&gt; novel) {
        this.novel = novel;
    }

    public List&lt;ArtAlbum&gt; getArtAlbum() {
        return artAlbum;
    }

    public void setArtAlbum(List&lt;ArtAlbum&gt; artAlbum) {
        this.artAlbum = artAlbum;
    }

    public void addNovel (Novel newNovel) {
        this.novel.add(newNovel);
    }
}
Design

Since duplicates are allowed (no Set required) and you don't need to fetch books by name (no Map required), ArrayList will do just fine.

Overview Collection Types

Guard public entrypoints

Make sure to checks arguments on all publically available code that takes input from calling code.

if (novels == null) throw new IllegalArgumentException("novels must be set");


Use plural for variable names that represent collections

private List&lt;Novel&gt; novels = new ArrayList&lt;&gt;();
private List&lt;ArtAlbum&gt; artAlbums = new ArrayList&lt;&gt;();


Initialize object members only once

Don't create the ArrayList instances twice. You can use addAll to add a range of items to a list. Perhaps you also want to create public methods to perform these actions.

public class LibraryCatalog {
        private List&lt;Novel&gt; novels = new ArrayList&lt;&gt;();
        private List&lt;ArtAlbum&gt; artAlbums = new ArrayList&lt;&gt;();

        public LibraryCatalog(List&lt;Novel&gt; novels, List&lt;ArtAlbum&gt; artAlbums) {
            if (novels == null)
                throw new IllegalArgumentException("novels must be set");
            if (artAlbums == null)
              throw new IllegalArgumentException("argument must be set");
            this.novels.addAll(novels);
            this.artAlbums.addAll(artAlbums);
        }
    }