Skip to content

Commit d3cecac

Browse files
Add files via upload
1 parent 19b7a9d commit d3cecac

34 files changed

+3540
-0
lines changed

BowlingAlley/code/BOWLERS.DAT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Mike M. J. Lutz [email protected]
2+
Jim J. R. Vallino [email protected]
3+
Tom T. R. Reichmayr [email protected]
4+
Lana L. R. Verschage [email protected]
5+
TomH T. Hilburn [email protected]
6+
hrk Husen Kagdi [email protected]
7+
HRK Husen Kagdi [email protected]
8+
hrk1 husen1 abc
9+
sid sidh abcd

BowlingAlley/code/SCOREHISTORY.DAT

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Mike 22:25 3/6/2004 130
2+
Jim 22:25 3/6/2004 113
3+
Tom 22:25 3/6/2004 105
4+
Lana 22:25 3/6/2004 130
5+
TomH 22:25 3/6/2004 125
6+
Mike 22:26 3/6/2004 153
7+
TomH 22:26 3/6/2004 174
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
package Views;
2+
/* AddPartyView.java
3+
*
4+
* Version:
5+
* $Id$
6+
*
7+
* Revisions:
8+
* $Log: AddPartyView.java,v $
9+
* Revision 1.7 2003/02/20 02:05:53 ???
10+
* Fixed addPatron so that duplicates won't be created.
11+
*
12+
* Revision 1.6 2003/02/09 20:52:46 ???
13+
* Added comments.
14+
*
15+
* Revision 1.5 2003/02/02 17:42:09 ???
16+
* Made updates to migrate to observer model.
17+
*
18+
* Revision 1.4 2003/02/02 16:29:52 ???
19+
* Added ControlDeskEvent and ControlDeskObserver. Updated Queue to allow access to Vector so that contents could be viewed without destroying. Implemented observer model for most of ControlDesk.
20+
*
21+
*
22+
*/
23+
24+
/**
25+
* Class for GUI components need to add a party
26+
*
27+
*/
28+
29+
import java.awt.*;
30+
import java.awt.event.*;
31+
import javax.swing.*;
32+
import javax.swing.event.*;
33+
34+
import models.Bowler;
35+
import controllers.BowlerFile;
36+
37+
import java.util.*;
38+
39+
/* Constructor for GUI used to Add Parties to the waiting party queue. */
40+
public class AddPartyView implements ListSelectionListener {
41+
private int maxSize;
42+
private JFrame win;
43+
private JButton addPatron, newPatron, remPatron, finished;
44+
private JList partyList, allBowlers;
45+
Vector party;
46+
47+
private Vector bowlerdb;
48+
49+
private AddPartyView addpartyView;
50+
private String selectedNick, selectedMember;
51+
52+
public AddPartyView(ControlDeskView controlDesk, int max) {
53+
this.addpartyView = this;
54+
maxSize = max;
55+
56+
win = new JFrame("Add Party");
57+
win.getContentPane().setLayout(new BorderLayout());
58+
((JPanel) win.getContentPane()).setOpaque(false);
59+
60+
JPanel colPanel = new JPanel();
61+
colPanel.setLayout(new GridLayout(1, 3));
62+
GeneralView gview=new GeneralView();
63+
64+
// Party Panel
65+
JPanel partyPanel = new JPanel();
66+
gview.setFlowLayout(partyPanel, "Your Party");
67+
68+
party = new Vector();
69+
Vector empty = new Vector();
70+
empty.add("(Empty)");
71+
72+
partyList = new JList(empty);
73+
gview.addJList(partyList, 5, 120);
74+
partyList.addListSelectionListener(this);
75+
JScrollPane partyPane = new JScrollPane(partyList);
76+
partyPanel.add(partyPane);
77+
78+
// Bowler Database
79+
JPanel bowlerPanel = new JPanel();
80+
gview.setFlowLayout(bowlerPanel, "Bowler Database");
81+
82+
try {
83+
bowlerdb = new Vector(BowlerFile.getBowlers());
84+
} catch (Exception e) {
85+
System.err.println("File Error");
86+
bowlerdb = new Vector();
87+
}
88+
allBowlers = new JList(bowlerdb);
89+
gview.addJList(allBowlers,8,120);
90+
JScrollPane bowlerPane = new JScrollPane(allBowlers);
91+
bowlerPane.setVerticalScrollBarPolicy(
92+
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
93+
allBowlers.addListSelectionListener(this);
94+
bowlerPanel.add(bowlerPane);
95+
96+
// Button Panel
97+
JPanel buttonPanel = new JPanel();
98+
buttonPanel.setLayout(new GridLayout(4, 1));
99+
100+
addPatron = new JButton("Add to Party");
101+
addPatron.addActionListener(new ActionListener() {
102+
@Override
103+
public void actionPerformed(ActionEvent e) {
104+
if (selectedNick != null && party.size() < maxSize) {
105+
if (party.contains(selectedNick)) {
106+
System.err.println("Member already in Party");
107+
} else {
108+
party.add(selectedNick);
109+
partyList.setListData(party);
110+
}
111+
}
112+
}
113+
});
114+
JPanel addPatronPanel = new JPanel();
115+
gview.addButton(addPatron, addPatronPanel);
116+
117+
remPatron = new JButton("Remove Member");
118+
remPatron.addActionListener(new ActionListener() {
119+
@Override
120+
public void actionPerformed(ActionEvent e) {
121+
if (selectedMember != null) {
122+
party.removeElement(selectedMember);
123+
partyList.setListData(party);
124+
}
125+
}
126+
});
127+
JPanel remPatronPanel = new JPanel();
128+
gview.addButton(remPatron,remPatronPanel);
129+
130+
newPatron = new JButton("New Patron");
131+
newPatron.addActionListener(new ActionListener() {
132+
@Override
133+
public void actionPerformed(ActionEvent e) {
134+
NewPatronView newPatron = new NewPatronView(addpartyView);
135+
}
136+
});
137+
JPanel newPatronPanel = new JPanel();
138+
gview.addButton(newPatron, newPatronPanel);
139+
140+
finished = new JButton("Finished");
141+
finished.addActionListener(new ActionListener() {
142+
@Override
143+
public void actionPerformed(ActionEvent e) {
144+
if ( party != null && party.size() > 0) {
145+
controlDesk.updateAddParty(addpartyView);
146+
}
147+
win.hide();
148+
}
149+
});
150+
JPanel finishedPanel = new JPanel();
151+
gview.addButton(finished, finishedPanel);
152+
153+
buttonPanel.add(addPatronPanel);
154+
buttonPanel.add(remPatronPanel);
155+
buttonPanel.add(newPatronPanel);
156+
buttonPanel.add(finishedPanel);
157+
158+
// Clean up main panel
159+
colPanel.add(partyPanel);
160+
colPanel.add(bowlerPanel);
161+
colPanel.add(buttonPanel);
162+
163+
win.getContentPane().add("Center", colPanel);
164+
165+
win.pack();
166+
167+
// Center Window on Screen
168+
Dimension screenSize = (Toolkit.getDefaultToolkit()).getScreenSize();
169+
win.setLocation(
170+
((screenSize.width) / 2) - ((win.getSize().width) / 2),
171+
((screenSize.height) / 2) - ((win.getSize().height) / 2));
172+
win.show();
173+
174+
}
175+
176+
177+
/**
178+
* Handler for List actions
179+
* @param e the ListActionEvent that triggered the handler
180+
*/
181+
182+
public void valueChanged(ListSelectionEvent e) {
183+
if (e.getSource().equals(allBowlers)) {
184+
selectedNick = ((String) ((JList) e.getSource()).getSelectedValue());
185+
}
186+
else if (e.getSource().equals(partyList)) {
187+
selectedMember = ((String) ((JList) e.getSource()).getSelectedValue());
188+
}
189+
}
190+
191+
/* Accessor for Party */
192+
public Vector getNames() {
193+
return party;
194+
}
195+
196+
/**
197+
* Called by NewPatronView to notify AddPartyView to update
198+
*
199+
* @param newPatron the NewPatronView that called this method
200+
*/
201+
202+
public void updateNewPatron(NewPatronView newPatron) {
203+
try {
204+
Bowler checkBowler = BowlerFile.getBowlerInfo( newPatron.getNick() );
205+
if ( checkBowler == null ) {
206+
BowlerFile.putBowlerInfo(
207+
newPatron.getNick(),
208+
newPatron.getFull(),
209+
newPatron.getEmail());
210+
bowlerdb = new Vector(BowlerFile.getBowlers());
211+
allBowlers.setListData(bowlerdb);
212+
party.add(newPatron.getNick());
213+
partyList.setListData(party);
214+
} else {
215+
System.err.println( "A Bowler with that name already exists." );
216+
}
217+
} catch (Exception e2) {
218+
System.err.println("File I/O Error");
219+
}
220+
}
221+
222+
/* Accessor for Party */
223+
public Vector getParty() {
224+
return party;
225+
}
226+
227+
}

0 commit comments

Comments
 (0)