Repository navigation
Expand file tree
/
Copy pathTestBook.java
More file actions
93 lines (93 loc) · 2.57 KB
/
Copy pathTestBook.java
File metadata and controls
93 lines (93 loc) · 2.57 KB
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
public class TestBook {
static class Book {
String BookName;
String AuthorName;
String email;
String gender;
double price;
int qty = 0;
Book(String BookName,String AuthorName, String email,String gender,double price)
{
this.BookName=BookName;
this.AuthorName=AuthorName;
this.email=email;
this.gender=gender;
this.price=price;
}
Book(String BookName,String AuthorName, String email,String gender,double price,int qty)
{
this.BookName=BookName;
this.AuthorName=AuthorName;
this.email=email;
this.gender=gender;
this.price=price;
this.qty=qty;
}
public String getName()
{
return BookName;
}
public String getAuthorName()
{
return AuthorName;
}
public String getAuthorEmail()
{
return email;
}
public String getAuthorGender()
{
return gender;
}
public double getPrice()
{
return price;
}
public void setPrice(double price)
{
this.price=price;
}
public int getQty()
{
return qty;
}
public void setQty(int qty)
{
this.qty=qty;
}
public String toString()
{
return ("Book[name="+BookName+",authors={Author[name="+AuthorName+",email="+email+",gender="+gender+"],price="+price+",qty="+qty);
}
public String getAuthorNames()
{
return ("AuthorNames:"+AuthorName);
}
}
public static void main(String args[])
{
int qty = 100;
Book B= new Book("MyWorld","Gemini","Geminilinjun@gmail.com","male",50,100);
String BookName;
String AuthorName;
String email;
String gender;
double price;
int quantity;
BookName =B.getName();
AuthorName=B.getAuthorName();
email=B.getAuthorEmail();
gender=B.getAuthorGender();
price=B.getPrice();
quantity=B.getQty();
String str1;
str1=B.toString();
System.out.println(str1);
System.out.println("BookName="+BookName);
System.out.println("AuthorName="+AuthorName);
System.out.println("Email="+email);
System.out.println("Gender="+gender);
System.out.println("Price="+price);
System.out.println("Quantity="+quantity);
}
}