The Artima Developer Community
Sponsored Link

Java Answers Forum
Adding and searching the data Task !

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Java

Posts: 1
Nickname: javaishard
Registered: Mar, 2005

Adding and searching the data Task ! Posted: Mar 2, 2005 10:00 AM
Reply to this message Reply
Advertisement
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.BookName);
System.out.println(bookdata.Isbn);
System.out.println(bookdata.NoOfStock);
System.out.println(bookdata.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.

Topic: Open IE from java Previous Topic   Next Topic Topic: a battleships game in java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use