Skip to content

Commit

Permalink
[Refactoring] Specifying the Type in ControlDesk.java
Browse files Browse the repository at this point in the history
  • Loading branch information
jjunjji committed May 30, 2023
1 parent dca7c36 commit b2ae48c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
33 changes: 16 additions & 17 deletions ControlDesk.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
class ControlDesk extends Thread {

/** The collection of Lanes */
private HashSet lanes;
private HashSet<Lane> lanes;

/** The party wait queue */
private Queue partyQueue;
Expand All @@ -55,12 +55,12 @@ class ControlDesk extends Thread {
private int numLanes;

/** The collection of subscribers */
private Vector subscribers;
private Vector<ControlDeskObserver> subscribers;

/**
* Constructor for the ControlDesk class
*
* @param numlanes the numbler of lanes to be represented
* @param numLanes the numbler of lanes to be represented
*
*/

Expand Down Expand Up @@ -127,10 +127,10 @@ private Bowler registerPatron(String nickName) {
*/

public void assignLane() {
Iterator it = lanes.iterator();
Iterator<Lane> it = lanes.iterator();

while (it.hasNext() && partyQueue.hasMoreElements()) {
Lane curLane = (Lane) it.next();
Lane curLane = it.next();

if (curLane.isPartyAssigned() == false) {
System.out.println("ok... assigning this party");
Expand All @@ -154,10 +154,10 @@ public void viewScores(Lane ln) {
*
*/

public void addPartyQueue(Vector partyNicks) {
Vector partyBowlers = new Vector();
public void addPartyQueue(Vector<String> partyNicks) {
Vector<Bowler> partyBowlers = new Vector();
for (int i = 0; i < partyNicks.size(); i++) {
Bowler newBowler = registerPatron(((String) partyNicks.get(i)));
Bowler newBowler = registerPatron((partyNicks.get(i)));
partyBowlers.add(newBowler);
}
Party newParty = new Party(partyBowlers);
Expand All @@ -172,11 +172,11 @@ public void addPartyQueue(Vector partyNicks) {
*
*/

public Vector getPartyQueue() {
Vector displayPartyQueue = new Vector();
for ( int i=0; i < ( (Vector)partyQueue.asVector()).size(); i++ ) {
public Vector<String> getPartyQueue() {
Vector<String> displayPartyQueue = new Vector();
for ( int i=0; i < ( partyQueue.asVector()).size(); i++ ) {
String nextParty =
((Bowler) ((Vector) ((Party) partyQueue.asVector().get( i ) ).getMembers())
((Bowler) ( ((Party) partyQueue.asVector().get( i ) ).getMembers())
.get(0))
.getNickName() + "'s Party";
displayPartyQueue.addElement(nextParty);
Expand Down Expand Up @@ -214,11 +214,10 @@ public void subscribe(ControlDeskObserver adding) {
*/

public void publish(PartyQueueEvent event) {
Iterator eventIterator = subscribers.iterator();
Iterator<ControlDeskObserver> eventIterator = subscribers.iterator();
while (eventIterator.hasNext()) {
(
(ControlDeskObserver) eventIterator
.next())
eventIterator
.next()
.receiveControlDeskEvent(
event);
}
Expand All @@ -231,7 +230,7 @@ public void publish(PartyQueueEvent event) {
*
*/

public HashSet getLanes() {
public HashSet<Lane> getLanes() {
return lanes;
}
}
6 changes: 3 additions & 3 deletions PartyQueueEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class PartyQueueEvent {

/** A representation of the wait queue, containing party names */
private Vector<Party> partyQueue;
private Vector<String> partyQueue;

/**
* Contstructor for the ControlDeskEvent
Expand All @@ -27,7 +27,7 @@ public class PartyQueueEvent {
*
*/

public PartyQueueEvent(Vector<Party> partyQueue ) {
public PartyQueueEvent(Vector<String> partyQueue ) {
this.partyQueue = partyQueue;
}

Expand All @@ -38,7 +38,7 @@ public PartyQueueEvent(Vector<Party> partyQueue ) {
*
*/

public Vector<Party> getPartyQueue() {
public Vector<String> getPartyQueue() {
return partyQueue;
}

Expand Down

0 comments on commit b2ae48c

Please sign in to comment.