Skip to content

Commit

Permalink
feat : scoreHistoryFile 리팩토링
Browse files Browse the repository at this point in the history
DIP 적용
  • Loading branch information
Kim-minseok123 committed May 30, 2023
1 parent e3a001c commit aba94d8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Lane.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ public void run() {
try{
Date date = new Date();
String dateString = "" + date.getHours() + ":" + date.getMinutes() + " " + date.getMonth() + "/" + date.getDay() + "/" + (date.getYear() + 1900);
ScoreHistoryFile.addScore(currentThrower.getNick(), dateString, new Integer(cumulScores[bowlIndex][9]).toString());
ScoreHistoryFile shf = new ScoreHistoryFile();
shf.addScore(currentThrower.getNick(), dateString, new Integer(cumulScores[bowlIndex][9]).toString());
} catch (Exception e) {System.err.println("Exception in addScore. "+ e );}
}

Expand Down
5 changes: 5 additions & 0 deletions ScoreHistoryReader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import java.io.*;
import java.util.*;
public interface ScoreHistoryReader {
Vector<Score> getScores(String nick) throws IOException,FileNotFoundException;
}
4 changes: 4 additions & 0 deletions ScoreHistoryWriter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import java.io.*;
public interface ScoreHistoryWriter {
void addScore(String nick, String date, String score) throws IOException, FileNotFoundException;
}
3 changes: 2 additions & 1 deletion ScoreReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public ScoreReport( Bowler bowler, int[] scores, int games) {
String nick = bowler.getNick();
String full = bowler.getFullName();
Vector v = null;
ScoreHistoryFile shf = new ScoreHistoryFile();
try{
v = ScoreHistoryFile.getScores(nick);
v = shf.getScores(nick);
} catch (Exception e){System.err.println("Error: " + e);}

Iterator scoreIt = v.iterator();
Expand Down

0 comments on commit aba94d8

Please sign in to comment.