-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoreReport.java
More file actions
54 lines (48 loc) · 1.39 KB
/
ScoreReport.java
File metadata and controls
54 lines (48 loc) · 1.39 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
/**
*
* SMTP implementation based on code by R�al Gagnon mailto:real@rgagnon.com
*
*/
import java.util.Vector;
import java.util.Iterator;
public class ScoreReport {
private ScoreReportSender sender;
private String content;
public ScoreReport( Bowler bowler, int[] scores, int games ) {
String nick = bowler.getNickName();
String full = bowler.getFullName();
Vector<Score> v = null;
ScoreHistoryFile shf = new ScoreHistoryFile();
try{
v = shf.getScores(nick);
} catch (Exception e){System.err.println("Error: " + e);}
Iterator<Score> scoreIt = v.iterator();
content = "";
content += "--Lucky Strike Bowling Alley Score Report--\n";
content += "\n";
content += "Report for " + full + ", aka \"" + nick + "\":\n";
content += "\n";
content += "Final scores for this session: ";
content += scores[0];
for (int i = 1; i < games; i++){
content += ", " + scores[i];
}
content += ".\n";
content += "\n";
content += "\n";
content += "Previous scores by date: \n";
while (scoreIt.hasNext()){
Score score = (Score) scoreIt.next();
content += " " + score.getDate() + " - " + score.getScore();
content += "\n";
}
content += "\n\n";
content += "Thank you for your continuing patronage.";
}
public void setSender(ScoreReportSender sender) {
this.sender = sender;
}
public void sendTo(String recipient) {
sender.send(recipient, this.content);
}
}