This commit is contained in:
2025-09-26 13:21:58 +02:00
parent 7c72e94d8d
commit e35f36db4b
4 changed files with 65 additions and 28 deletions

View File

@@ -1,26 +1,16 @@
import java.sql.ResultSet;
import java.sql.SQLException;
public class Main {
public static void main(String[] args) {
Database database = new Database();
String country = "France";
ResultSet result = database.getVotesFromCompetitor(country);
Votes votesForItaly = database.getVotesFromCompetitor("Italie");
try {
while(result.next()) {
System.out.println(country + " -> " + result.getString("name") + " : " + result.getInt("points"));
}
} catch(SQLException exception) {
System.err.println("Error while read the data from the result.");
System.out.println("Vote " + votesForItaly.getCompetitorName() + " :");
for(Vote vote : votesForItaly.getVoters()) {
System.out.println(vote.getVoterName() + " " + vote.getPoints());
}
try {
result.close();
} catch(SQLException exception) {
System.err.println("Error while trying to close the result.");
}
System.out.println("-------------------");
System.out.println("Total " + votesForItaly.getTotalPoints());
}
}