Skip to content

Commit 2991326

Browse files
ChidiebereChidiebere
authored andcommitted
All main functionality thus far have been tested ok
Tests on all the classes have been completed and they have all been confirmed working. The next step is to blitz through the android app and complete it quickly
1 parent ff36ade commit 2991326

33 files changed

Lines changed: 463 additions & 243 deletions

‎ModualrProject/src/database/bean/Bean.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.List;
77
import java.util.stream.Collectors;
88

9-
import database.managers.DatabaseManager;
9+
import database.managers.ConnectionManager;
1010
import utils.ValidationType;
1111

1212
/**This interface is used to mark all the classes that represent a single row of a
@@ -154,7 +154,7 @@ public static boolean hasOnlyNumbers(String string)
154154
* @return
155155
*/
156156
public static boolean validateDate(Date earlier, Date later){
157-
Date currentDate = DatabaseManager.getCurrentDate();
157+
Date currentDate = ConnectionManager.getCurrentDate();
158158
return earlier !=null && later != null &&
159159
( earlier.before(later) || earlier.equals( later ) ) &&
160160
( currentDate.after(earlier) || currentDate.equals(earlier)) &&

‎ModualrProject/src/database/bean/ModuleRegister.java‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.sql.Date;
44

5+
import database.bean.student.Student;
56
import utils.ValidationType;
67

78
/**
@@ -122,7 +123,7 @@ public void setStudentId(String studentId)
122123
*{@link database.managers.ModuleRegisterManager#getModRegById(int) }
123124
* @return true when module has been paid for
124125
*/
125-
public boolean hasPaid()
126+
public boolean paymentComplete()
126127
{
127128
return paymentStatus;
128129
}
@@ -264,14 +265,12 @@ public boolean validateModuleName()
264265
}
265266

266267
/**
267-
* Checks that the studentId is valid by ensuring that it contains only
268-
* letters and numbers.
269-
* @return {@code true} if the studentId is valid
268+
* Checks that the studentId is valid vial call to
269+
* {@link database.bean.student.Student#validateStudentID(String)}
270270
*/
271271
public boolean validateStudentId()
272272
{
273-
String name = getStudentId();
274-
return name != null && Bean.containsEitherAlphaNum(name) ;
273+
return Student.validateStudentID(getStudentId());
275274
}
276275

277276
public double getTotalPriceForModule()

‎ModualrProject/src/database/bean/Payment.java‎

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
*/
2020
public class Payment implements Bean
2121
{
22-
22+
2323
private static final long serialVersionUID = 6495853015546110411L;
2424
private int id;
2525
private int regId;
2626
private double amount;
2727
private String bankName;
2828
private String tellerNumber;
2929
private Date paymentDate;
30-
31-
30+
31+
3232
public Payment( int id , int modRegId, double amount, String bank ,
3333
String tellerNum , Date payDate ){
3434
setId(id);
@@ -38,15 +38,25 @@ public Payment( int id , int modRegId, double amount, String bank ,
3838
setTellerNumber(tellerNum);
3939
setPaymentDate(payDate);
4040
}
41+
42+
public Payment( int modRegId, double amount, String bank ,
43+
String tellerNum , Date payDate ){
44+
setModuleRegisterId(modRegId);
45+
setAmount(amount);
46+
setBankName(bank);
47+
setTellerNumber(tellerNum);
48+
setPaymentDate(payDate);
49+
}
50+
4151
public Payment(){}
42-
52+
4353
/**
4454
* Gets the id of this {@code Payment} object as an {@code int}
4555
* @return
4656
*/
4757
public int getId()
4858
{
49-
return id;
59+
return id;
5060
}
5161

5262
/**
@@ -56,7 +66,7 @@ public int getId()
5666
*/
5767
public void setId(int id)
5868
{
59-
this.id = id;
69+
this.id = id;
6070
}
6171

6272
/**
@@ -65,7 +75,7 @@ public void setId(int id)
6575
*/
6676
public int getRegId()
6777
{
68-
return regId;
78+
return regId;
6979
}
7080

7181
/**
@@ -75,7 +85,7 @@ public int getRegId()
7585
*/
7686
public void setModuleRegisterId(int moduleRegisterId)
7787
{
78-
this.regId = moduleRegisterId;
88+
this.regId = moduleRegisterId;
7989
}
8090

8191
/**
@@ -84,7 +94,7 @@ public void setModuleRegisterId(int moduleRegisterId)
8494
*/
8595
public double getAmount()
8696
{
87-
return amount;
97+
return amount;
8898
}
8999

90100
/**
@@ -93,7 +103,7 @@ public double getAmount()
93103
*/
94104
public void setAmount(double amount)
95105
{
96-
this.amount = amount;
106+
this.amount = amount;
97107
}
98108

99109
/**
@@ -102,9 +112,9 @@ public void setAmount(double amount)
102112
*/
103113
public String getBankName()
104114
{
105-
return bankName;
115+
return bankName;
106116
}
107-
117+
108118
/**
109119
* Capitalizes the first letter in each word in the {@code String} passed
110120
* as an argument and uses it to set the name of the bank in which this
@@ -113,7 +123,7 @@ public String getBankName()
113123
*/
114124
public void setBankName(String bankName)
115125
{
116-
this.bankName = Bean.capitalizeWords( bankName);
126+
this.bankName = Bean.capitalizeWords( bankName);
117127
}
118128

119129
/**
@@ -122,7 +132,7 @@ public void setBankName(String bankName)
122132
*/
123133
public String getTellerNumber()
124134
{
125-
return tellerNumber;
135+
return tellerNumber;
126136
}
127137

128138
/**
@@ -131,7 +141,7 @@ public String getTellerNumber()
131141
*/
132142
public void setTellerNumber(String tellerNumber)
133143
{
134-
this.tellerNumber = tellerNumber.replaceAll("\\s{1,}", "");
144+
this.tellerNumber = tellerNumber.replaceAll("\\s{1,}", "");
135145
}
136146

137147
/**
@@ -140,7 +150,7 @@ public void setTellerNumber(String tellerNumber)
140150
*/
141151
public Date getPaymentDate()
142152
{
143-
return paymentDate;
153+
return paymentDate;
144154
}
145155

146156
/**
@@ -149,7 +159,7 @@ public Date getPaymentDate()
149159
*/
150160
public void setPaymentDate(Date paymentDate)
151161
{
152-
this.paymentDate = paymentDate;
162+
this.paymentDate = paymentDate;
153163
}
154164

155165
/**
@@ -169,14 +179,13 @@ public boolean isValid(ValidationType type)
169179
switch( type){
170180
case NEW_BEAN:
171181
return validateTellerNumber() && validateAmount() &&
172-
validateModuleRegId() && validateBankName() &&
173-
validateId();
182+
validateModuleRegId() && validateBankName() ;
174183
case EXISTING_BEAN:
175184
return validateId();
176185
}
177186
return false;
178187
}
179-
188+
180189
/**
181190
* Checks that the id attribute stored in this object is greater than 0
182191
* @return {@code true } if the id is greater than zero
@@ -194,7 +203,7 @@ public boolean validateId()
194203
public boolean validateTellerNumber(){
195204
return Bean.hasOnlyNumbers( getTellerNumber());
196205
}
197-
206+
198207
/**
199208
* Checks that the amount paid is greater than zero
200209
* @return {@code true} if the payment has been done
@@ -210,10 +219,10 @@ public boolean validateAmount(){
210219
public boolean validateModuleRegId(){
211220
return getRegId() > 0;
212221
}
213-
222+
214223
public boolean validateBankName(){
215224
String bankName = getBankName();
216225
return bankName !=null && bankName.length()>0;
217-
226+
218227
}
219228
}

‎ModualrProject/src/database/bean/student/JobResponsibility.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public String getRole()
5353
*/
5454
public void setRole(String role)
5555
{
56-
this.role = Bean.removeExtraSpaces(role);
56+
this.role = Bean.capitalizeWords(role);
5757
}
5858

5959
/**

‎ModualrProject/src/database/bean/student/MeanOfDiscovery.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public String getMeans()
7474
*/
7575
public void setMeans(String means)
7676
{
77-
this.means = Bean.removeExtraSpaces( means);
77+
this.means = Bean.capitalizeWords( means);
7878
}
7979

8080
/**

‎ModualrProject/src/database/bean/student/Sponsor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public String getEmail()
127127
*/
128128
public void setEmail(String email)
129129
{
130-
this.email = Bean.removeExtraSpaces( email );
130+
this.email =email.replaceAll( "\\s", "");
131131
}
132132

133133
/**

0 commit comments

Comments
 (0)