Repository navigation
Expand file tree
/
Copy pathPaymentTest2.java
More file actions
67 lines (56 loc) · 1.94 KB
/
Copy pathPaymentTest2.java
File metadata and controls
67 lines (56 loc) · 1.94 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
package test;
import java.sql.SQLException;
import java.text.ParseException;
import database.bean.Admin;
import database.bean.ModuleRegister;
import database.bean.Payment;
import database.managers.ConnectionManager;
import database.managers.DatabaseManager;
import database.managers.ModuleRegisterManager;
import database.managers.PaymentManager;
import exception.InvalidAdminException;
import utils.BeanType;
import utils.ValidationType;
public class PaymentTest2
{
public static void main(String[] args) throws ParseException
{
Admin currentAdmin = new Admin("Chidi", "OguejioforTheGreat" );
DatabaseManager.setCurrentAdmin(currentAdmin);
// Rest of the code
try
{
System.out.println("----AVAILABLE PAYMENTs----");
TestUtils.displayBean( BeanType.MODULE_REGISTER , 0);
int modRegId = Integer.parseInt(TestUtils.getStringInput("Enter ModuleRegister ID: ") );
double amount = Double.parseDouble(TestUtils.getStringInput("Input Amount Paod: " ));
Payment payment = new Payment( modRegId, amount);
ModuleRegister modReg = ModuleRegisterManager.getModRegById(modRegId);
if( PaymentManager.makePayment(modRegId)){
System.out.println("Successfully made the required payment" );
}
else if( PaymentManager.isPaymentComplete(payment.getRegId())){
System.err.println("Payment unsuccessful because it is complete" );
}
else if(!modReg.hasBooked() ){
System.err.println("Failed because module has not yet been booked");
}
else
{
System.err.println("Payment was unsuccessful for unknown reasons");
}
}
catch ( InvalidAdminException e)
{
System.err.println( e );
System.err.println("The Admin was invalid");
}
catch (SQLException e){
e.printStackTrace();
}
finally{
// This is also very important. Close the ConnectionManager
ConnectionManager.close();
}
}
}