Repository navigation
Expand file tree
/
Copy pathStatsTest.java
More file actions
87 lines (74 loc) · 2.82 KB
/
Copy pathStatsTest.java
File metadata and controls
87 lines (74 loc) · 2.82 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
package test;
import java.sql.SQLException;
import java.util.Arrays;
import database.bean.Admin;
import database.bean.Certificate;
import database.bean.Module;
import database.bean.student.Student;
import database.managers.ConnectionManager;
import database.managers.DatabaseManager;
import database.statistics.CertificateStats;
import database.statistics.ModuleStats;
import database.statistics.StatisticsManager;
import database.statistics.StudentModuleStats;
import database.statistics.StudentStats;
import database.statistics.TableStats;
public class StatsTest
{
public static void main(String[] args)
{
DatabaseManager.setCurrentAdmin( new Admin("Chidiebere", "Fred"));
Student student = new Student("EMY-C4340");
Module mod = new Module("Electrical Installation");
Certificate cert = new Certificate("Electrotechnics");
StudentStats studStats = null ;//use for graph
ModuleStats modStats =null;
CertificateStats certStats = null;
StudentModuleStats[] studMods= null ; //use for the table
TableStats stat = null ;
try
{
studStats = StatisticsManager.retrieveStats(student);
modStats = StatisticsManager.retrieveStats(mod);
certStats = StatisticsManager.retrieveStats(cert);
stat = StatisticsManager.retrieveStats();
studMods = StatisticsManager.retrieveStudentModuleStats(
student.getIdCardNumber());
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("---Student Stats------");
System.out.println(studStats);
System.out.println("------ModuleTabTable Stats---------");
System.out.println(modStats);
System.out.println("-------Certificate Stats-----" );
System.out.println( certStats);
System.out.println("--------Database Stats--------");
System.out.println(stat);
System.out.println(Arrays.toString(studMods));
System.out.println("Individual cert stat");
String cert1[][] = stat.getIndividualCertStats();
for ( int row = 0; row < cert1.length; row++ ){
// loop through columns of current row
for ( int column = 0; column < cert1[ row ].length; column++ )
System.out.printf( "%s ", cert1[ row ][ column ] );
System.out.println(); // start new line of output
} // end outer for
System.out.println("--------StudentModule Stats--------");
if(studMods != null ){
for( StudentModuleStats studMod : studMods){
System.out.printf("Date Regisetered: %s%nModule Name: %s%nAmount Paid : %.2f%n"
+ "Booked: %s%nResult: %s%nPayment Status: %s%n->%n",
studMod.getDateRegistered(), studMod.getModuleName(),
studMod.getAmountPaid(), studMod.hasBooked(), studMod.getResult(),
studMod.isPaymentComplete()) ;
}
}else{
System.out.println("The student has not registered for any Module");
}
ConnectionManager.close();
}
}