in this code snippet
public void push(Book book) {
if(size() == capacity)
doubleStackArray();
stack[++top] = book;//***
if i want to push a a Book object, I am stuck at //***
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
in this code snippet
public void push(Book book) {
if(size() == capacity)
doubleStackArray();
stack[++top] = book;//***
if i want to push a a Book object, I am stuck at //***
Please explain what the problem is. What is the stack variable? It is coded like an array.
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
If you don't understand my answer, don't ignore it, ask a question.
In fact
1.I have created a Book class which contains the above book attributes and accessor methods.
2.Then, I created the BookApp class where I input the values for attributes and create an object of Book class and parameters.
The problem comes here----->>>
2. I created a BookStack class which contains the stack methods but for the push method, I cannot pass a book object as parameter..plz help.
Is my logic OK?
question was:
Write a program that keeps the following information on books:
• Book title
• Barcode
• Author Name
• Price
• Edition
Books from ten different authors need to be piled in such a way that the user can access the
information of one book at a time.
Note: Use an array implementation for the stack.
Your program should validate the following:
• Addition of more than 10 books to your stack.
• Deletion of books when your stack is empty.
Please post the full text of any error messages.I cannot pass a book object as parameter
Or explain what the problem is.
The code needs to be in code tags, not quote tags.
If you don't understand my answer, don't ignore it, ask a question.