title: Issue with a method for a library of objects
body: <p>I'm trying to make a program that creates a library of different books, I have set a number of copies for each item in the library and every time I check out an Item I want it to deduct 1 copy from only the particular object I check out but instead it takes a copy away from all the objects. not sure how to fix the problem. </p>
  
  <pre><code>public abstract class Item{
    private int identify;
    private String title;
    private int copies;
  
    public Item(){
      identify=0;
      title="N/A";
      copies=0;
    }
    public Item(int id, int copy, String t){
      identify=id;
      copies=copy;
      title=t;
    }
    public void setIdentificationNumber(int id){
      identify = id;
    }
    public void setTitle(String t){
      title=t;
    }
    public void setNumberCopies(int num){
      copies=num;
    }
    public int getIdentificationNumber(){
      return identify;
    }
    public String getTitle(){
      return title;
    }
    public int getNumberCopies(){
      return copies;
    }
    public void checkOut(){
      if(copies&gt;0){
        copies-=1;
        System.out.println("You have checked out "+title+". Thank You");
      }
      else{
        System.out.println("All copies of "+title+" are checked out!");
      }
    }
    public void checkIn(){
      copies+=1;
    }
  }
  </code></pre>
  
  <p>The problem may also be in my client method I have posted the code for that as well below.</p>
  
  <pre><code>import java.util.Arrays;
  import java.util.Scanner;
  public class Library{
    static String title;
    static String author;
    static int id;
    static int copies;
    static String date;
    static Book[] database = new Book[100];
    static int count=0;
  
    public static void main(String[] args){
      int i;
      Scanner s = new Scanner(System.in);
      do{
        addBook();
        System.out.println("would you like to add another book?");
        i=s.nextInt();
      }while(i == 0);
      database[0].viewDetails();
      database[1].viewDetails();
      checkingOut();
      database[0].viewDetails();
      database[1].viewDetails();
    }
    public static void addBook(){
      Scanner s = new Scanner(System.in);
      System.out.println("Enter the title of the book you want to add to the collection");
      title=s.nextLine();
      System.out.println("Enter the author of the book you want to add to the collection");
      author=s.nextLine();
      System.out.println("Enter the publishing date of the book you want to add to the collection");
      date=s.nextLine();
      System.out.println("Enter the ID number of the book you want to add to the collection");
      id=s.nextInt();
      System.out.println("Enter the the number of copies that will be added into the collection");
      copies=s.nextInt();
  
      Book Book1 = new Book(date, author, copies, id, title);
      database[count] = Book1;
      count++;
    }
    public static void checkingOut(){
      boolean found=false;
      int idSearch;
      int i=0;
      Scanner s = new Scanner(System.in);
      System.out.println("Enter the ID number of the book you want to check out");
      idSearch=s.nextInt();
      while(i&lt;database.length &amp;&amp; found!=true){
        if(database[i].getIdentificationNumber() == idSearch){
          found = true;
        }
        i++;
      }
      if(found==true){
        database[i].checkOut();
        System.out.println("There are "+database[i].getNumberCopies()+" copies left");
      }
      else{System.out.println("There is no book with that ID number!");}
    }
  }
  </code></pre>
  
  <p>In my addBook method I create a new object called book1 every time I make a new book, so I think that it may be changing all of the book objects every time I add a book. I'm not really sure of a better way to write the method.</p>
  
  <p>here is my method for book also</p>
  
  <pre><code>public class Book extends WrittenItem{
    public Book(){
      super();
    }
    public Book(String date, String a, int copy, int id, String t){
      super(a, date, copy, id, t);
  
    }
    public void viewDetails(){
      System.out.println("ID: "+getIdentificationNumber()+"\nTitle: "+getTitle()+"\nAuthor: "+getAuthor()+" Date written: "+getDate()+"\nCopies available: "+getNumberCopies());
    }
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>