here is assignment create a book class with getter ans setters. create a driver class book_driver, and create an array or arraylist to hol at least four books.
built the book class, built the book driver, having problem successfully building the array. I have not finshed the book driver; as i am making changes to it to except user input. question I have is after looking at about 20 million post on using and arraylist none have answered my questions? i need to store 4 book made up of elements like author,title, publisher , and ISBN. How do you store all 4 strings in an object that object being the book in the arraylist?
public class Book {
private String Title;
private String Author;
private String Publisher;
private Integer ISBN;
public Book()
{
}
public void setTitle(String title)
{
Title = title;
}
public void setAuthor(String author)
{
Author = author;
}
public void setPublisher(String publisher)
{
Publisher = publisher;
}
public void setIsbn(Integer Isbn)
{
ISBN =Isbn;
}
public String getTitle()
{
return Title;
}
public String getAuthor()
{
return Author;
}
public String getPublisher()
{
return Publisher;
}
public Integer getIsbn()
{
return ISBN;
}}//End class
import java.util.Scanner;
public class book_driver {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Book book=new Book();
String a_title;
String a_author;
String a_publisher;
int a_isbn;
System.out.print("Enter Book's Title:\n ");
a_title=input.nextLine();
book.setTitle(a_title);
System.out.print("Enter Book's Author:\n ");
a_author=input.nextLine();
book.setAuthor(a_author);
System.out.print("Enter Book's Publisher:\n ");
a_publisher=input.nextLine();
book.setPublisher(a_publisher);
System.out.print("Enter Book's ISBN:\n ");
a_isbn=input.nextInt();
book.setIsbn(a_isbn);
}}
import java.util.ArrayList;
public class Bookcase {
public ArrayList<Bookcase> mybooks=new ArrayList<Bookcase>();
public Bookcase(String title, String author, String publisher, String string)
{
}}//End Class