forked from java-tester-x/JavaExercises4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBook.java
More file actions
73 lines (58 loc) · 1.6 KB
/
Book.java
File metadata and controls
73 lines (58 loc) · 1.6 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
package src;
/**
* A class called circle is designed as shown in the following class diagram. It contains:
*
* 1) Two private instance variables: radius (of type double) and color (of type String),
* with default value of 1.0 and "red", respectively.
* 2) Two overloaded constructors;
* 3) Two public methods: getRadius() and getArea().
*
* The source codes for Circle is as follows:
*/
public class Book {
private String name;
private double price;
private Author author;
private int qtyInStock = 0;
public Book (String name, Author author, double price) {
this.name = name;
this.author = author;
this.price = price;
}
public Book (String name, Author author, double price, int qtyInStock) {
this.name = name;
this.author = author;
this.price = price;
this.qtyInStock = qtyInStock;
}
public String getName() {
return this.name;
}
public Author getAuthor() {
return this.author;
}
public double getPrice() {
return this.price;
}
public void setPrice(double price) {
this.price = price;
}
public int getQtyInStock() {
return this.qtyInStock;
}
public void setQtyInStock(int qtyInStock) {
this.qtyInStock = qtyInStock;
}
public String getAuthorName() {
return this.author.getName();
}
public String getAuthorEmail() {
return this.author.getEmail();
}
public char getAuthorGender() {
return this.author.getGender();
}
public String toString() {
return "'" + name +"' by " + author;
}
}