-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
117 lines (110 loc) · 3.51 KB
/
Copy pathStudent.java
File metadata and controls
117 lines (110 loc) · 3.51 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import java.lang.*;
import java.util.*;
public class Student {
private StudentData login_student;
public Student(){
}
public void run_student_subprog(String id){
Scanner input = new Scanner(System.in);
String buffer;
String bufbook;
int index;
boolean isnum;
boolean needext;
login_student = LibraryDatabase.loadStudent(id);
do{
LibraryDatabase.viewStudents(id);
System.out.print("ID:" + login_student.id + ">");
buffer = input.nextLine();
if(buffer.equals("exit")){
break;
}else if(buffer.equals("borrow")){
System.out.print("ID:" + login_student.id + "-borrow>");
System.out.print("\nBookname or Booknum?");
buffer = input.nextLine();
if(buffer.equals("booknum")){
isnum = true;
bufbook = input.nextLine();
needext = LibraryDatabase.borrowBook(login_student, bufbook, isnum);
}else if(buffer.equals("bookname")){
isnum = false;
bufbook = input.nextLine();
needext = LibraryDatabase.borrowBook(login_student, bufbook, isnum);
}else{
continue;
}
if(needext){
System.out.print("(y/n)?");
buffer = input.nextLine();
if(buffer.charAt(0) == 'y' || buffer.charAt(0) == 'Y'){
LibraryDatabase.reserveBook(login_student, bufbook, isnum);
}
}
}else if(buffer.equals("return")){
System.out.print("ID:" + login_student.id + "-return>");
System.out.print("\nBookname or Booknum?");
buffer = input.nextLine();
if(buffer.equals("booknum")){
isnum = true;
buffer = input.nextLine();
LibraryDatabase.returnBook(login_student, buffer, isnum);
}else if(buffer.equals("bookname")){
isnum = false;
buffer = input.nextLine();
LibraryDatabase.returnBook(login_student, buffer, isnum);
}
}else if(buffer.equals("reserve")){
System.out.print("ID:" + login_student.id + "-reserve>");
System.out.print("\nBookname or Booknum?");
buffer = input.nextLine();
if(buffer.equals("booknum")){
isnum = true;
bufbook = input.nextLine();
needext = LibraryDatabase.reserveBook(login_student, bufbook, isnum);
}else if(buffer.equals("bookname")){
isnum = false;
bufbook = input.nextLine();
needext = LibraryDatabase.reserveBook(login_student, bufbook, isnum);
}else{
continue;
}
if(needext){
System.out.print("[y/n]");
buffer = input.nextLine();
if(buffer.charAt(0) == 'y' || buffer.charAt(0) == 'Y'){
LibraryDatabase.borrowBook(login_student, bufbook, isnum);
}
}
}else if(buffer.equals("reservecancel")){
System.out.print("ID:" + login_student.id + "-return>");
System.out.print("\nBookname or Booknum?");
buffer = input.nextLine();
if(buffer.equals("booknum")){
isnum = true;
buffer = input.nextLine();
LibraryDatabase.cancelReserveBook(login_student, buffer, isnum);
}else if(buffer.equals("bookname")){
isnum = false;
buffer = input.nextLine();
LibraryDatabase.cancelReserveBook(login_student, buffer, isnum);
}
}else if(buffer.equals("search")){
while(true){
System.out.print("ID:" + login_student.id + "-search>");
buffer = input.nextLine();
if(buffer.equals("exit")){
break;
}
try{
index = Integer.parseInt(buffer);
if(index < 4){
buffer = input.nextLine();
}
LibraryDatabase.viewBooks(index, buffer);
}catch(Exception e){
}
}
}
}while(true);
}
}