Skip to content

Commit 8434699

Browse files
committed
converted to MVC structure and changes in control desk
1 parent 0b17c63 commit 8434699

33 files changed

+171
-339
lines changed

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>SE_Project</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

BowlingAlley/code/AddPartyView.java renamed to BowlingAlley/code/Views/AddPartyView.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package Views;
12
/* AddPartyView.java
23
*
34
* Version:
@@ -31,6 +32,9 @@
3132
import javax.swing.border.*;
3233
import javax.swing.event.*;
3334

35+
import models.Bowler;
36+
import controllers.BowlerFile;
37+
3438
import java.util.*;
3539
import java.text.*;
3640

@@ -48,7 +52,9 @@ public class AddPartyView implements ActionListener, ListSelectionListener {
4852
private JFrame win;
4953
private JButton addPatron, newPatron, remPatron, finished;
5054
private JList partyList, allBowlers;
51-
private Vector party, bowlerdb;
55+
Vector party;
56+
57+
private Vector bowlerdb;
5258
private Integer lock;
5359

5460
private ControlDeskView controlDesk;

BowlingAlley/code/ControlDeskView.java renamed to BowlingAlley/code/Views/ControlDeskView.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package Views;
12
/* ControlDeskView.java
23
*
34
* Version:
@@ -12,14 +13,30 @@
1213
* Class for representation of the control desk
1314
*
1415
*/
15-
16-
import java.awt.*;
17-
import java.awt.event.*;
18-
import javax.swing.*;
19-
import javax.swing.border.*;
20-
import javax.swing.event.*;
21-
22-
import java.util.*;
16+
import java.awt.BorderLayout;
17+
import java.awt.Dimension;
18+
import java.awt.FlowLayout;
19+
import java.awt.Toolkit;
20+
import java.awt.event.ActionEvent;
21+
import java.awt.event.ActionListener;
22+
import java.awt.event.WindowAdapter;
23+
import java.awt.event.WindowEvent;
24+
import java.util.HashSet;
25+
import java.util.Iterator;
26+
import java.util.Vector;
27+
28+
import javax.swing.JButton;
29+
import javax.swing.JFrame;
30+
import javax.swing.JList;
31+
import javax.swing.JPanel;
32+
import javax.swing.JScrollPane;
33+
import javax.swing.border.TitledBorder;
34+
35+
import controllers.ControlDeskEvent;
36+
import controllers.ControlDeskObserver;
37+
import models.ControlDesk;
38+
import models.Lane;
39+
import models.Pinsetter;
2340

2441
public class ControlDeskView implements ActionListener, ControlDeskObserver {
2542

BowlingAlley/code/GeneralView.java renamed to BowlingAlley/code/Views/GeneralView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package Views;
12
import javax.swing.JList;
23
import javax.swing.JPanel;
34
import javax.swing.border.TitledBorder;

BowlingAlley/code/LaneStatusView.java renamed to BowlingAlley/code/Views/LaneStatusView.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package Views;
12
/**
23
*
34
* To change this generated comment edit the template variable "typecomment":
@@ -12,6 +13,14 @@
1213
import javax.swing.border.*;
1314
import javax.swing.event.*;
1415

16+
import controllers.PinsetterEvent;
17+
import controllers.PinsetterObserver;
18+
import models.Bowler;
19+
import models.Lane;
20+
import controllers.LaneEvent;
21+
import controllers.LaneObserver;
22+
import models.Pinsetter;
23+
1524
public class LaneStatusView implements ActionListener, LaneObserver, PinsetterObserver {
1625

1726
private JPanel jp;
@@ -133,7 +142,7 @@ public void actionPerformed( ActionEvent e ) {
133142
}
134143

135144
public void receiveLaneEvent(LaneEvent le) {
136-
curBowler.setText( ( (Bowler)le.getBowler()).getNickName() );
145+
curBowler.setText( ( (Bowler)le.getBowler()).getNick() );
137146
if ( le.isMechanicalProblem() ) {
138147
maintenance.setBackground( Color.RED );
139148
}

BowlingAlley/code/LaneView.java renamed to BowlingAlley/code/Views/LaneView.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package Views;
12
/*
23
* constructs a prototype Lane View
34
*
@@ -6,6 +7,13 @@
67
import java.awt.*;
78
import java.awt.event.*;
89
import javax.swing.*;
10+
11+
import models.Bowler;
12+
import models.Lane;
13+
import controllers.LaneEvent;
14+
import controllers.LaneObserver;
15+
import models.Party;
16+
917
import java.util.*;
1018

1119
public class LaneView implements LaneObserver, ActionListener {

BowlingAlley/code/NewPatronView.java renamed to BowlingAlley/code/Views/NewPatronView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package Views;
12
/* AddPartyView.java
23
*
34
* Version

BowlingAlley/code/PinSetterView.java renamed to BowlingAlley/code/Views/PinSetterView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package Views;
12
/*
23
* PinSetterView/.java
34
*
@@ -16,6 +17,10 @@
1617
import java.awt.*;
1718
import java.awt.event.*;
1819
import javax.swing.*;
20+
21+
import controllers.PinsetterEvent;
22+
import controllers.PinsetterObserver;
23+
1924
import java.util.Vector;
2025

2126

BowlingAlley/code/BowlerFile.java renamed to BowlingAlley/code/controllers/BowlerFile.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/* BowlerFile.java
23
*
34
* Version:
@@ -20,9 +21,12 @@
2021
*/
2122

2223
import java.util.*;
24+
25+
import models.Bowler;
26+
2327
import java.io.*;
2428

25-
class BowlerFile {
29+
public class BowlerFile {
2630

2731
/** The location of the bowelr database */
2832
private static String BOWLER_DAT = "D:\\iiith\\git_repo\\IIITH\\assignments\\SE\\BowlingAlley\\code\\BOWLERS.DAT";

BowlingAlley/code/ControlDeskEvent.java renamed to BowlingAlley/code/controllers/ControlDeskEvent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/* ControlDeskEvent.java
23
*
34
* Version:

BowlingAlley/code/ControlDeskObserver.java renamed to BowlingAlley/code/controllers/ControlDeskObserver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/* ControlDeskObserver.java
23
*
34
* Version

BowlingAlley/code/EndGamePrompt.java renamed to BowlingAlley/code/controllers/EndGamePrompt.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/**
23
*
34
* To change this generated comment edit the template variable "typecomment":

BowlingAlley/code/EndGameReport.java renamed to BowlingAlley/code/controllers/EndGameReport.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/**
23
*
34
* To change this generated comment edit the template variable "typecomment":
@@ -12,6 +13,9 @@
1213
import javax.swing.border.*;
1314
import javax.swing.event.*;
1415

16+
import models.Bowler;
17+
import models.Party;
18+
1519
import java.util.*;
1620
import java.text.*;
1721

BowlingAlley/code/LaneEvent.java renamed to BowlingAlley/code/controllers/LaneEvent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/* $Id$
23
*
34
* Revisions:
@@ -25,6 +26,9 @@
2526

2627
import java.util.HashMap;
2728

29+
import models.Bowler;
30+
import models.Party;
31+
2832
public class LaneEvent {
2933

3034
private Party p;

BowlingAlley/code/LaneEventInterface.java renamed to BowlingAlley/code/controllers/LaneEventInterface.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
package controllers;
12
import java.util.HashMap;
23

4+
import models.Bowler;
5+
import models.Party;
6+
37
public interface LaneEventInterface extends java.rmi.Remote {
48
public int getFrameNum( ) throws java.rmi.RemoteException;
59
public HashMap getScore( ) throws java.rmi.RemoteException;

BowlingAlley/code/LaneObserver.java renamed to BowlingAlley/code/controllers/LaneObserver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/* $Id$
23
*
34
* Revisions:

BowlingAlley/code/LaneServer.java renamed to BowlingAlley/code/controllers/LaneServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
public interface LaneServer extends java.rmi.Remote {
23
public void subscribe(LaneObserver toAdd) throws java.rmi.RemoteException;
34
};

BowlingAlley/code/PinsetterEvent.java renamed to BowlingAlley/code/controllers/PinsetterEvent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/* $Id$
23
*
34
* Revisions:

BowlingAlley/code/PinsetterObserver.java renamed to BowlingAlley/code/controllers/PinsetterObserver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/* $Id$
23
*
34
* Revisions:

BowlingAlley/code/PrintableText.java renamed to BowlingAlley/code/controllers/PrintableText.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/**
23
*
34
*/

BowlingAlley/code/Queue.java renamed to BowlingAlley/code/controllers/Queue.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/* Queue.java
23
*
34
* Version

BowlingAlley/code/ScoreHistoryFile.java renamed to BowlingAlley/code/controllers/ScoreHistoryFile.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/**
23
*
34
* To change this generated comment edit the template variable "typecomment":
@@ -7,6 +8,9 @@
78
*/
89

910
import java.util.*;
11+
12+
import models.Score;
13+
1014
import java.io.*;
1115

1216
public class ScoreHistoryFile {

BowlingAlley/code/ScoreReport.java renamed to BowlingAlley/code/controllers/ScoreReport.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package controllers;
12
/**
23
*
34
* SMTP implementation based on code by Réal Gagnon mailto:[email protected]
@@ -7,6 +8,10 @@
78

89
import java.io.*;
910
import java.util.Vector;
11+
12+
import models.Bowler;
13+
import models.Score;
14+
1015
import java.util.Iterator;
1116
import java.net.*;
1217
import java.awt.*;

BowlingAlley/code/SimulateThrow.java renamed to BowlingAlley/code/controllers/SimulateThrow.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
package controllers;
12
import java.util.Random;
23

34
public class SimulateThrow {
45

5-
boolean foul;
6+
public boolean foul;
67
public boolean[] pins;
78
private Random rnd;
89
public SimulateThrow()

BowlingAlley/code/scoreCalcualte.java renamed to BowlingAlley/code/controllers/scoreCalculate.java

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
package controllers;
12
import java.io.Serializable;
23
import java.util.HashMap;
34

4-
class scoreCalculate implements Serializable {
5+
import models.Bowler;
6+
import models.Lane;
7+
import models.Party;
8+
9+
public class scoreCalculate implements Serializable {
510
public final HashMap scores;
611
public Party party;
712
public boolean partyAssigned;
@@ -22,14 +27,7 @@ public HashMap getScores() {
2227
return scores;
2328
}
2429

25-
/** resetScores()
26-
*
27-
* resets the scoring mechanism, must be called before scoring starts
28-
*
29-
* @pre the party has been assigned
30-
* @post scoring system is initialized
31-
*/
32-
public void resetScores(Party party) {
30+
public void resetScores(Party party) {
3331

3432
for (Object o : party.getMembers()) {
3533
int[] toPut = new int[25];
@@ -40,11 +38,7 @@ public void resetScores(Party party) {
4038
}
4139
}
4240

43-
/** markScore()
44-
*
45-
* Method that marks a bowlers score on the board.
46-
*
47-
*/
41+
4842
public void markScore(Lane lane,int ball,int score){
4943
int[] curScore;
5044
int index = ( lane.frameNumber * 2 + ball);
@@ -109,16 +103,7 @@ else if (curScore[i] != -1) {
109103
}
110104
}
111105

112-
/** getScore()
113-
*
114-
* Method that calculates a bowlers score
115-
*
116-
* @param Cur The bowler that is currently up
117-
* @param frame The frame the current bowler is on
118-
*
119-
* @param cumulScores
120-
* @return The bowlers total score
121-
*/
106+
122107

123108
public void getScore(Bowler Cur, int frame, int[][] cumulScores, int bowlIndex, int ball) {
124109
int[] curScore;

BowlingAlley/code/drive.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import java.util.Vector;
2+
3+
import Views.ControlDeskView;
4+
import models.Alley;
5+
import models.ControlDesk;
6+
27
import java.io.*;
38

49
public class drive {

BowlingAlley/code/Alley.java renamed to BowlingAlley/code/models/Alley.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package models;
2+
13
/*
24
* Alley.java
35
*

BowlingAlley/code/Bowler.java renamed to BowlingAlley/code/models/Bowler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package models;
12
/*
23
* Bowler.java
34
*

0 commit comments

Comments
 (0)