-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBook.java
84 lines (71 loc) · 1.87 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
public class Book {
private int id;
private String author;
private String subject;
private String borrower;
private boolean avail;
public void setbook(int id, String raw) {
this.id = id;
String sp[] = raw.split(" ");
this.author = sp[0];
this.subject = sp[1];
this.borrower = "none";
this.avail = true;
}
public void print() {
System.out.print("ID: " + id
+ " Author: " + author
+ " Subject: " + subject + "\n");
}
public String printfile() {
return ("ID: " + id
+ " Author: " + author
+ " Subject: " + subject + "\n");
}
public void setid(String id) {
if (id.isBlank()) {
System.out.println("id not be empty!");
} else {
this.id = Integer.parseInt(id);
}
}
public void setauthor(String author) {
if (author.isBlank()) {
System.out.println("author not be empty!");
} else {
this.author = author;
}
}
public void setsubject(String subject) {
if (subject.isBlank()) {
System.out.println("subject not be empty!");
} else {
this.subject = subject;
}
}
public void setborrower(String borrower) {
if (borrower.isBlank()) {
// System.out.println("borrower not be empty!");
} else {
this.borrower = borrower;
}
}
public void setavail(boolean avail) {
this.avail = avail;
}
public int getid() {
return this.id;
}
public String getauthor() {
return this.author;
}
public String getsubject() {
return this.subject;
}
public String getborrower() {
return this.borrower;
}
public boolean getavail() {
return this.avail;
}
}