-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuthor.java
104 lines (93 loc) · 1.44 KB
/
Author.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import java.util.Scanner;
public class Author
{
String name;
String email;
char gender;
Author()
{}
Author(String name1,String email1,char gender1)
{
this.name=name1;
this.email=email1;
this.gender=gender1;
}
String getName()
{
return name;
}
String getEmail()
{
return email;
}
void setemail(String mail)
{
this.email=mail;
}
char getgender()
{
return gender;
}
String toString2()
{
String str="Author"+this.name+"email"+this.email+"gender"+this.gender;
return str;
}
}
class book {
String bname;
double bprice;
int bqty;
Author bauthor;
book(String name,Author author,double price)
{
this.bname=name;
this.bauthor=author;
this.bprice=price;
}
book(String name,Author author,double price,int qty)
{
this.bname=name;
this.bauthor=author;
this.bprice=price;
this.bqty=qty;
}
String getname()
{
return bname;
}
Author getauthor()
{
return bauthor;
}
Double getprice()
{
return bprice;
}
void setprice(Double price)
{
this.bprice=price;
}
int getqty()
{
return bqty;
}
void setqty(int qty)
{
this.bqty=qty;
}
String toString1()
{
String ptr="BOOK"+this.bname+"author"+this.bauthor+"quantity"+this.bqty+"price"+this.bprice;
return ptr;
}
public static void main(String a1[])
{
Scanner sc=new Scanner(System.in);
Author a=new Author("shreya","DSfgdf",'m');
book b=new book("java",a,100);
book b2=new book("java",a,100,3);
System.out.println("author details"+a.toString2());
System.out.println("book details"+b.toString1());
}
}