Skip to content

Commit

Permalink
feat : 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-minseok123 committed Jun 4, 2023
1 parent 3205fc8 commit 552adb0
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion BowlerFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class BowlerFile implements BowlerDatabase {

/** The location of the bowelr database */
private static String BOWLER_DAT = "/Users/yeonjoo/Desktop/pattern_team/BallingManagementSystem_refactoring/BOWLERS.DAT";
private static String BOWLER_DAT = "BOWLERS.DAT";

private BowlerFile() {}

Expand Down
8 changes: 4 additions & 4 deletions EndGameReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class EndGameReport {
public EndGameReport( String partyName, Party party ) {

result =0;
retVal = new Vector<String>();
retVal = new Vector<>();
win = new JFrame("End Game Report for " + partyName + "?" );
win.getContentPane().setLayout(new BorderLayout());
((JPanel) win.getContentPane()).setOpaque(false);
Expand All @@ -41,13 +41,13 @@ public EndGameReport( String partyName, Party party ) {
partyPanel.setLayout(new FlowLayout());
partyPanel.setBorder(new TitledBorder("Party Members"));

Vector<String> myVector = new Vector<String>();
Vector<String> myVector = new Vector<>();
Iterator<Bowler> iter = (party.getMembers()).iterator();
while (iter.hasNext()){
myVector.add((iter.next()).getNickName() );
}
EndGameReportClickEvent listener = new EndGameReportClickEvent();
memberList = new JList<String>(myVector);
memberList = new JList<>(myVector);
memberList.setFixedCellWidth(120);
memberList.setVisibleRowCount(5);
memberList.addListSelectionListener(listener);
Expand Down Expand Up @@ -118,7 +118,7 @@ public Vector<String> getretVal(){
return retVal;
}
public static void main( String args[] ) {
Vector<Bowler> bowlers = new Vector<Bowler>();
Vector<Bowler> bowlers = new Vector<>();
for ( int i=0; i<4; i++ ) {
bowlers.add( new Bowler( "aaaaa", "aaaaa", "aaaaa" ) );
}
Expand Down
12 changes: 4 additions & 8 deletions Lane.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,7 @@ public int promptEndGame(){ // 게임 종료를 위한 응답 반영

public void printEndGameReportAndNotifyMembers(){ // 점수 보고서 생성 및 출력
Vector<String> printVector;
EndGameReport egr = new EndGameReport( ((Bowler)party.getMembers().get(0)).getNickName() + "'s Party", party);
// TODO: (Bowler) 지우려면 party.getMember type 지정해야 함.
EndGameReport egr = new EndGameReport((party.getMembers().get(0)).getNickName() + "'s Party", party);
printVector = egr.waitForResult();
partyAssigned = false;
Iterator<Bowler> scoreIt = party.getMembers().iterator();
Expand Down Expand Up @@ -377,7 +376,7 @@ public void resetBowlerIterator() {
* @post scoring system is initialized
*/
public void resetScores() {
Iterator<String> bowlIt = (party.getMembers()).iterator();
Iterator<Bowler> bowlIt = (party.getMembers()).iterator();

while ( bowlIt.hasNext() ) {
int[] toPut = new int[25];
Expand Down Expand Up @@ -455,9 +454,8 @@ private LaneEvent lanePublish( ) {
*
* @return The bowlers total score
*/
private int getScore( Bowler Cur, int frame) { // 전략 패턴 도입
private void getScore( Bowler Cur, int frame) { // 전략 패턴 도입
int[] curScore;
int totalScore = 0;
curScore = scores.get(Cur);
for (int i = 0; i != 10; i++){
cumulScores[bowlIndex][i] = 0;
Expand All @@ -474,9 +472,7 @@ private int getScore( Bowler Cur, int frame) { // 전략 패턴 도입
strategy = new DefaultScoringStrategy();
}
strategy.computeScore(curScore, cumulScores, bowlIndex, current, i);

}
return totalScore;
}

/** isPartyAssigned()
Expand All @@ -501,7 +497,7 @@ public boolean isGameHalted(){
return gameIsHalted;
}

public Iterator getBowlIterator(){
public Iterator<Bowler> getBowlIterator(){
return bowlerIterator;
}
/** subscribe
Expand Down
2 changes: 1 addition & 1 deletion LaneEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class LaneEvent {
int[] curScores;
boolean mechProb;

public LaneEvent( Party pty, int theIndex, Bowler<Bowler , int[]> theBowler, int[][] theCumulScore, HashMap theScore, int theFrameNum, int[] theCurScores, int theBall, boolean mechProblem) {
public LaneEvent( Party pty, int theIndex, Bowler theBowler, int[][] theCumulScore, HashMap<Bowler , int[]>theScore, int theFrameNum, int[] theCurScores, int theBall, boolean mechProblem) {
p = pty;
index = theIndex;
bowler = theBowler;
Expand Down
6 changes: 3 additions & 3 deletions Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import java.util.Vector;

public class Queue {
private Vector v;
private Vector<Object> v;

/** Queue()
*
* creates a new queue
*/
public Queue() {
v = new Vector();
v = new Vector<>();
}

public Object next() {
Expand All @@ -33,7 +33,7 @@ public boolean hasMoreElements() {
return v.size() != 0;
}

public Vector asVector() {
public Vector<Object> asVector() {
return v;
}

Expand Down
8 changes: 8 additions & 0 deletions SCOREHISTORY.DAT
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ Tom 22:34 06/01/2023 149
Jim 22:34 06/01/2023 102
Tom 22:40 06/01/2023 99
TomH 22:40 06/01/2023 108
Tom 14:20 06/04/2023 127
Mike 14:20 06/04/2023 153
Mike 14:35 06/04/2023 126
Tom 14:35 06/04/2023 141
Mike 14:50 06/04/2023 152
Jim 14:50 06/04/2023 177
Mike 14:51 06/04/2023 111
Jim 14:51 06/04/2023 129
4 changes: 2 additions & 2 deletions ScoreHistoryFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class ScoreHistoryFile implements ScoreHistoryReader, ScoreHistoryWriter {

private static String SCOREHISTORY_DAT = "/Users/yeonjoo/Desktop/pattern_team/BallingManagementSystem_refactoring/SCOREHISTORY.DAT";
private static String SCOREHISTORY_DAT = "SCOREHISTORY.DAT";

public void addScore(String nick, String date, String score)
throws IOException, FileNotFoundException {
Expand All @@ -26,7 +26,7 @@ public void addScore(String nick, String date, String score)

public Vector<Score> getScores(String nick)
throws IOException, FileNotFoundException {
Vector<Score> scores = new Vector<Score>();
Vector<Score> scores = new Vector<>();

BufferedReader in =
new BufferedReader(new FileReader(SCOREHISTORY_DAT));
Expand Down
2 changes: 1 addition & 1 deletion ScoringStrategy.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
interface ScoringStrategy { // 심볼 표시와 점수 계산 인터페이스
String getScoreSymbol(int[] bowlerScores, int ballIndex);

void computeScore(int[] curScore, int[][] cumulScores, int bowlIndex, int current, int i);
void computeScore(int[]curScore, int[][] cumulScores, int bowlIndex, int current, int i);
}

0 comments on commit 552adb0

Please sign in to comment.