-
Notifications
You must be signed in to change notification settings - Fork 0
/
Book.java
66 lines (65 loc) · 1.36 KB
/
Book.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class Book
{
private String name;
private int qty;
private double prize;
private Author s1[];
public Book(String name,double prize,Auther s1[])
{
this.name=name;
this.prize=prize;
this.s1=s1;
}
public Book(String name,double prize,Auther [] s1,int qty)
{
this.name=name;
this.prize=prize;
this.s1=s1;
this.qty=qty;
}
public String getName()
{
return name;
}
public Author getAuthor()
{
return s1;
}
public void setPrize(double prize)
{
this.prize=prize;
}
public double getPrize()
{
return prize;
}
public void setQty()
{
this.qty=qty;
}
public int getQty()
{
return qty;
}
public String toString()
{
String autherList="";
for(int i=0;i<s1.length;i++)
{
autherList+=s[i].toString();
}
String s="Book[ name: "+name+", author {"+ autherList +" prize= "+prize+"qty= "+qty+" ]";
return s;
}
public static void main(String []arg)
{
Author auth1=new Author("Inayat","[email protected]",'m');
Author auth2=new Author("Inayat","[email protected]",'m');
Author auth3=new Author("Inayat","[email protected]",'m');
Author auth4=new Author("Inayat","[email protected]",'m');
Author auth5=new Author("Inayat","[email protected]",'m');
Author[] a1={auth1,auth2,auth3,auth4,auth5};
Book b1=new Book("Inayat",1.2,a1,22);
System.out.println(b1.toString());
}
}