OK, so we had to create like a bookshelf and book objects with publisher, author, copyright date, etc. on a seperate file (basically creating an object for a driver class). I've redone this twice now this week and still get the same error. Perhaps someone could point me in the right direction? Maybe I'm missing something, I'm not sure. EDIT: the problem is: sorry I'm getting ready for work and going ahead of myself I have three: first the output is giving me: Book@15db9742 Book@6d06d69c then the book class for the year is red saying to convert from a string to an int so I do then it wants to go back the other way
public class Book {
private String title;
private String author;
private String publisher;
private int copyDate;
public Book(String bookTitle, String authorName, String publisherName, int bookYear){
title = bookTitle;
author = authorName;
publisher = publisherName;
copyDate = bookYear;
}
public Book(){
title = "book titler";
author = "author name";
publisher = "book publisher";
copyDate = "2014";
}
public String getTitle() {
return title;
}
public void setTitle(String bookTitle) {
title=bookTitle;
}
public String getAuthor() {
return author;
}
public void setAuthor(String authorName) {
author = authorName;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisherName) {
publisher = publisherName;
}
public int getCopyDate() {
return copyDate;
}
public void setCopyDate(int copyDate) {
this.copyDate = copyDate;
}
}
Here is the main class:
public class BookShelf {
public static void main(String[] args) {
int bookYear = 2014;
Book name1 = new Book("book\n", "something\n", "something else\n", bookYear);
Book name2 = new Book("anotherBook\n", "anotherSomething\n", "somethingElse^2\n", bookYear);
System.out.println(name1);
System.out.println(name2);
}
}
I entered arbitrary information so I can make sure it works before I go searching for a good book to enter the information for lol.
Thank you!