package Library.ru.mai.pmoproject;

import java.util.HashMap;
import java.util.List;

/**
 * Created by stud on 16.04.2015.
 */
public class Book {
    String Name;
    String Author;
    Integer ID;
    Integer quantity;

    public Book(String Name, String Author, Integer quantity){
        this.Name=Name;
        this.Author=Author;
        this.quantity=quantity;
        this.ID=ID;
        }

    @Override
    public String toString() {
        return "Book{" +
                "Name='" + Name + '\'' +
                ", Author='" + Author + '\'' +
                ", ID=" + ID +
                ", quantity=" + quantity +
                '}';
    }


    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public String getAuthor() {
        return Author;
    }

    public void setAuthor(String author) {
        Author = author;
    }

    public Integer getID(){
return ID;
    }



    public void setID(Integer ID) {
        this.ID = ID;
    }

    public Book add(Book book, List i) {
        book.quantity=quantity++;
        for (int n=0; n<i.size(); n++)
        {
            if (i.contains(book.Author))
            {
                int index = i.indexOf(book.Name);
                i.set(index, book.quantity);
            }
            else
            {
                System.out.println("Не подходит по автору");
            }
        }
        return null;
    }

    public Book add(Book book, HashMap i){
        book.quantity=quantity++;
        for (int n=0; n<i.size(); n++)
        {
            if (i.contains(book.Author))
            {
                int index = i.indexOf(book.Name);
                i.set(index, book.quantity);
            }
            else
            {
                System.out.println("Не подходит по автору");
            }
        }
        return null;
    }

    public Book subtract(Book book, List i) {
        book.quantity=quantity--;
        for (int n=0; n<i.size(); n++)
        {
            if (i.contains(book.Author))
            {
                int index = i.indexOf(book.Name);
                i.set(index, book.quantity);
            }
            else
            {
                System.out.println("Не подходит по автору");
            }
        }
        return null;
    }
}
