import
java.io.*;
interface bookinfo
{ public
void getbookdata()throws IOException;
public
void putbookdata();
}
interface basicinfo
{ public
void getbasicdata()throws IOException;
public
void putbasicdata();
}
interface otherinfo
{ public
void getotherdata()throws IOException;
public
void putotherdata();
}
class book implements bookinfo,basicinfo,otherinfo
{ String
Bname,Bauthor, Blanguage,Bpublisher;
int Bprice, Bcopies,Byear;
BufferedReader
br=new BufferedReader(new
InputStreamReader(System.in));
public void getbookdata()throws IOException
{ System.out.println("Enter
the Book name:");
Bname=br.readLine();
System.out.println("Enter
the author's name:");
Bauthor=br.readLine();
}
public void putbookdata()
{
System.out.print(Bname+"\t"+Bauthor+"\t");
}
public void getbasicdata()throws IOException
{ System.out.println("Enter
the language:");
Blanguage=br.readLine();
System.out.println("Enter
the published year:");
Byear=Integer.parseInt(br.readLine());
System.out.println("Enter
the price");
Bprice=Integer.parseInt(br.readLine());
}
public void putbasicdata()
{ System.out.print(Blanguage+"\t\t"+Byear+"\t"+Bprice+"\t");
}
public void getotherdata()throws IOException
{ System.out.println("Enter
the number of copies:");
Bcopies=Integer.parseInt(br.readLine());
System.out.println("Enter
the publisher:");
Bpublisher=br.readLine();
}
public void putotherdata()
{ System.out.print(Bcopies+"\t"+Bpublisher+"\t\t");
}
}
class interfaceEg
{
public static void main(String s[])throws
IOException
{
book it[];
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("How much
entries..?");
int k=Integer.parseInt(br.readLine());
it=new book[k];
for(int i=0;i<k;i++)
{ it[i]=new book();
}
for(int i=0;i<k;i++)
{
int j=i+1;
System.out.println("ENTER DETAILS OF
THE BOOK : "+j);
it[i].getbookdata();
it[i].getbasicdata();
it[i].getotherdata();
}
System.out.println("\n\n***********-----------------Book
details-----------------************\n");
System.out.println("Book\tAuthor\tLanguage\tYear\tPrice\tCopies
\tPublisher");
System.out.println("............................................................................");
for(int i=0;i<k;i++)
{
it[i].putbookdata();
it[i].putbasicdata();
it[i].putotherdata();
}} } Output |
This blog is mainly developed for individuals,who were interested in programming using C,C++,java and SQL.
Awesome. I am a beginner and this article helped me to resolve the problem .Thank you author and the whole expect team.
ReplyDeletehttp://www.wikitechy.com/view-article/simple-program-for-multiple-inheritance-using-cpp-with-example
Both are really good,
Cheers,
Venkat