IN THE NAME OF GOD
hello
this program is not run in java & i will be thanked that you answer me
we must define 2 class named book that have name of book id number of book & it price &class bookstore that has its name & we must define 2 object of bookstore & print the name of bookstore that has the most price of its books.
class book
{
private String name;
private String idnum;
private int pri;
public void setb(String n,String id,int p)
{name=n;
idnum=id;
pri=p;}
book(String cn,String cid,int cp)
{setb(cn,cid,cp);}
public String getname()
{return name;}
public String getidnum()
{return idnum;}
public int getpri()
{return pri;}
public String toString()
{return name+" "+idnum+" "+pri;}
public int f(book []b)
{
int sum=0;
for(int i=0;i<2;i++)
sum+=b[i].pri;
return sum;
}}
class bookstore
{
bookstore()
{}
private book b;
private String namestore;
public void set(String n,book l)
{
namestore=n;
b=b.setb(l);}
bookstore(String cn,book cl)
{set(cn,cl);}
public int compareto(bookstore s)
{
return sum-s.sum;
}
public String toString(book l)
{return namestore+" "+l.toString;}
}
class B
{
public static void main(String []w)
{
book []c=new book[2];
book []b=new book[2];
bookstore b1=new bookstore("fg",b);
bookstore c2=new bookstore("gf",c);
b[0]=new book("b1","1",100);
b[1]=new book("b2","12",120);
c[0]=new book("c1","2",106);
c[1]=new book("c2","21",190);
if(b1.compareto(c2)>0)
System.out.println(b1);
else System.out.println(c2);
} }