Hey Guys !
Can someone please guide me, I have created a program but it's incomplete, can anyone tell me what to do further!
The task is:
Write a
java program which defines and implements an appropriate set of attributes for a Book class. Implement two polymorphic add() methods for adding a current instance of a Book to an Array and an instance of a book to a another Book object.
The code I wrote:
class book
{
String BookName;
String Isbn;
int NoOfStock;
String Author;
public static void main(String[]args)
{
book[] bookdata= new book[10];
bookdata[0]=new book();
bookdata[0].BookName="Visual Basic";
bookdata[0].Isbn="E12";
bookdata[0].NoOfStock=2;
bookdata[0].Author="David";
bookdata[1]=new book();
bookdata[1].BookName="Java 2";
bookdata[1].Isbn="R29";
bookdata[1].NoOfStock=1;
bookdata[1].Author="Schildt";
for(int i=0; i<2;i++){
System.out.println(bookdata[i].BookName);
System.out.println(bookdata[i].Isbn);
System.out.println(bookdata[i].NoOfStock);
System.out.println(bookdata[i].Author);
}
}
}
What to do NOW ??? I've added the books but how will I add another book and check it ! and can I do it through parameter ?
take care all.