-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathBorrower.java
182 lines (137 loc) · 4.7 KB
/
Borrower.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package library;
import java.util.*;
import java.io.*;
/**
*
* @author Minahil Imtiaz
*/
public class Borrower extends Users {
private String address;
private String telephone;
private boolean fine_defaulter;
private double fine;
private ArrayList<Loan> BookLoans;
Borrower() {
super();
fine_defaulter = false;
BookLoans = null;
fine = 0.0;
address = " ";
telephone = " ";
BookLoans = new ArrayList<>();
}
Borrower(int user_id, String user_name, char gender, String telephone, String address, boolean fine_defaulter, double fine) {
super(user_id, user_name, gender);
this.fine_defaulter = fine_defaulter;
this.fine = fine;
this.address = address;
this.telephone = telephone;
BookLoans = new ArrayList<>();
}
@Override
public boolean GetFineStatus() {
// return this.fine_defaulter;
dbConnectivity db = new dbConnectivity();
return (db.GetFineStatus(this.GetId()));
}
public double GetFineAmout() {
// return this.fine;
dbConnectivity db = new dbConnectivity();
return (db.GetFineAmount(this.GetId()));
}
public String GetAddress() {
return this.address;
}
public String GetTelephone() {
return this.telephone;
}
@Override
public boolean SetFineStatus(boolean fine_defaulter) {
this.fine_defaulter = fine_defaulter;
dbConnectivity db = new dbConnectivity();
boolean result = db.SetFineStatus(this.GetId(), fine_defaulter);
return result;
}
public boolean SetTelephone(String Telephone) {
this.telephone = Telephone;
dbConnectivity db = new dbConnectivity();
boolean result = db.SetTelephone(this.GetId(), this.telephone);
return result;
}
public boolean SetAddress(String Address) {
this.address = Address;
dbConnectivity db = new dbConnectivity();
boolean result = db.SetAddress(this.GetId(), this.address);
return result;
}
@Override
public void SetFineAmount(double user_fine) {
this.fine = user_fine;
dbConnectivity db = new dbConnectivity();
boolean result = db.SetFineAmount(this.GetId(), user_fine);
}
public void SetName(String name)
{
super.SetName(name);
dbConnectivity db = new dbConnectivity();
boolean result = db.SetName(this.GetId(), name);
}
public void SetGender(char g)
{
super.SetGender(g);
dbConnectivity db = new dbConnectivity();
boolean result = db.SetGender(this.GetId(), g);
}
@Override
public boolean AddLoanInfo(Loan LoanInfo) {
BookLoans.add(LoanInfo);
return true;
// dbConnectivity db = new dbConnectivity ();
// boolean result=db.AddLoanInfo(this.GetId(), LoanInfo);
// return result;
}
public void AllLoansofUser(ArrayList<Loan> LoansofUser) {
// this.BookLoans=LoansofUser;
dbConnectivity db = new dbConnectivity();
this.BookLoans = db.LoadLoanListofSpecificUser(this.GetId());
}
//helping function to update loan info
@Override
public void UpdateLoanInfo(Loan Update, int book_id) {
// Iterator<Loan> itr = BookLoans.Iterator(BookLoans.size());
// while (itr.hasPrevious()) {
//
// Loan L = itr.previous();
for (int counter=BookLoans.size()-1 ; counter >=0; counter--){
Loan L = BookLoans.get(counter);
if ((L.GetaBookId() == book_id)) {
L.SetLoan(Update);
break;
}
}
}
//needed to be checked
@Override
public String ViewInformation(ArrayList<Loan> LoanList, int user_id) {
String Resultant="";
Resultant=Resultant+super.PrintInformation();
Resultant+="Adress :" + address+" ";
Resultant+="Telephone:" + telephone+" ";
Resultant+="\n Loan Info \n";
if (BookLoans.isEmpty() == false) {
for (int i=0;i< BookLoans.size();i++) {
Loan L=BookLoans.get(i);
Resultant+=L.PrintLoanInfo();
Resultant+="\n";
}
} else {
Resultant +="NO LOANS TILL YET!";
}
return Resultant;
}
}