nus-yam/ex-repair huggingface dataset:
Program: 173845
Project: 173845
Buggy source:
public void setHexModel(MapHex model){
  this.model=model;
  currentTile=model.getCurrentTile();
  hexName=model.getName();
  currentTileId=model.getPreprintedTileId();
  currentTileOrientation=model.getPreprintedTileOrientation();
  currentGUITile=new GUITile(currentTileId,model);
  currentGUITile.setRotation(currentTileOrientation);
  setToolTip();
  if (StatusWindow.useObserver) {
    model.addObserver(this);
  }
}

Fixed version (ground truth):
public void setHexModel(MapHex model){
  this.model=model;
  currentTile=model.getCurrentTile();
  hexName=model.getName();
  currentTileId=model.getCurrentTile().getId();
  currentTileOrientation=model.getCurrentTileRotation();
  currentGUITile=new GUITile(currentTileId,model);
  currentGUITile.setRotation(currentTileOrientation);
  setToolTip();
  if (StatusWindow.useObserver) {
    model.addObserver(this);
  }
}
Program: 173848
Project: 173848
Buggy source:
/** 
 * Check if a player may buy the given number of shares from a given company.
 * @param company The company from which to buy
 * @param number The number of shares (usually 1 but not always so).
 * @return True if it is allowed.
 */
public boolean mayBuyCompanyShare(PublicCompanyI company,int number){
  if (portfolio.ownsShare(company) + number * company.getShareUnit() > playerShareLimit)   return false;
  return true;
}

Fixed version (ground truth):
/** 
 * Check if a player may buy the given number of shares from a given company.
 * @param company The company from which to buy
 * @param number The number of shares (usually 1 but not always so).
 * @return True if it is allowed.
 */
public boolean mayBuyCompanyShare(PublicCompanyI company,int number){
  if (portfolio.ownsShare(company) + number * company.getShareUnit() > playerShareLimit && !company.getCurrentPrice().isNoHoldLimit())   return false;
  return true;
}
Program: 173849
Project: 173849
Buggy source:
/** 
 * Create a list of certificates that a player may sell in a Stock Round, taking all rules taken into account.
 * @return List of sellable certificates.
 */
public List getSellableCerts(){
  List sellableCerts=new ArrayList();
  if (!mayCurrentPlayerSellAtAll())   return sellableCerts;
  List certs;
  PublicCertificateI cert;
  TradeableCertificate tCert;
  PublicCompanyI comp;
  String compName;
  int price;
  for (Iterator it=currentPlayer.getPortfolio().getUniqueTradeableCertificates().iterator(); it.hasNext(); ) {
    tCert=(TradeableCertificate)it.next();
    cert=tCert.getCert();
    comp=cert.getCompany();
    compName=comp.getName();
    if (cert.getShare() + pool.ownsShare(comp) > Bank.getPoolShareLimit()) {
      continue;
    }
    if (cert.isPresidentShare()) {
      boolean victimFound=false;
      Player[] players=GameManager.getPlayers();
      for (int i=0; i < numberOfPlayers; i++) {
        if (players[i] == currentPlayer)         continue;
        if (players[i].getPortfolio().ownsShare(comp) >= cert.getShare()) {
          victimFound=true;
          break;
        }
      }
      if (!victimFound)       continue;
    }
    if (sellPrices.containsKey(compName)) {
      price=cert.getShares() * ((StockSpaceI)sellPrices.get(compName)).getPrice();
      tCert.setPrice(price);
    }
    sellableCerts.add(tCert);
  }
  return sellableCerts;
}

Fixed version (ground truth):
/** 
 * Create a list of certificates that a player may sell in a Stock Round, taking all rules taken into account.
 * @return List of sellable certificates.
 */
public List getSellableCerts(){
  List sellableCerts=new ArrayList();
  if (!mayCurrentPlayerSellAtAll())   return sellableCerts;
  List certs;
  PublicCertificateI cert;
  TradeableCertificate tCert;
  PublicCompanyI comp;
  String compName;
  int price;
  for (Iterator it=currentPlayer.getPortfolio().getUniqueTradeableCertificates().iterator(); it.hasNext(); ) {
    tCert=(TradeableCertificate)it.next();
    cert=tCert.getCert();
    comp=cert.getCompany();
    compName=comp.getName();
    if (cert.isPresidentShare()) {
      if (comp.getShareUnit() + pool.ownsShare(comp) > Bank.getPoolShareLimit()) {
        continue;
      }
      boolean victimFound=false;
      Player[] players=GameManager.getPlayers();
      for (int i=0; i < numberOfPlayers; i++) {
        if (players[i] == currentPlayer)         continue;
        if (players[i].getPortfolio().ownsShare(comp) >= cert.getShare()) {
          victimFound=true;
          break;
        }
      }
      if (!victimFound)       continue;
    }
 else {
      if (cert.getShare() + pool.ownsShare(comp) > Bank.getPoolShareLimit()) {
        continue;
      }
    }
    if (sellPrices.containsKey(compName)) {
      price=cert.getShares() * ((StockSpaceI)sellPrices.get(compName)).getPrice();
      tCert.setPrice(price);
    }
    sellableCerts.add(tCert);
  }
  return sellableCerts;
}
Program: 173852
Project: 173852
Buggy source:
public static void setNoSaleInFirstSR(){
  noSaleInFirstSR=true;
}

Fixed version (ground truth):
/** 
 * Can the current player do any buying?
 * @return True if any buying is allowed.
 */
public static void setNoSaleInFirstSR(){
  noSaleInFirstSR=true;
}
Program: 173855
Project: 173855
Buggy source:
public void layTile(MapHex hex,TileI tile,int orientation){
  if (!(round instanceof OperatingRound))   return;
  oRound=(OperatingRound)round;
  if (tile == null) {
    oRound.skip(orCompName);
  }
 else {
    if (oRound.layTile(orCompName,hex,tile,orientation)) {
      int cost=oRound.getLastTileLayCost();
      tileCost[orCompIndex].setText(cost > 0 ? Bank.format(cost) : "String_Node_Str");
      tiles[orCompIndex].setText(oRound.getLastTileLaid());
    }
 else {
      displayError();
    }
    button3.setEnabled(true);
  }
  LogWindow.addLog();
  if (oRound.getStep() != OperatingRound.STEP_LAY_TRACK) {
    this.requestFocus();
  }
  updateStatus();
}

Fixed version (ground truth):
public void layTile(MapHex hex,TileI tile,int orientation){
  if (!(round instanceof OperatingRound))   return;
  oRound=(OperatingRound)round;
  if (tile == null) {
    oRound.skip(orCompName);
  }
 else {
    int cost=oRound.getLastTileLayCost();
    tileCost[orCompIndex].setText(cost > 0 ? Bank.format(cost) : "String_Node_Str");
    tiles[orCompIndex].setText(oRound.getLastTileLaid());
    button3.setEnabled(true);
  }
  LogWindow.addLog();
  if (oRound.getStep() != OperatingRound.STEP_LAY_TRACK) {
    this.requestFocus();
  }
  updateStatus();
  return;
}
Program: 173856
Project: 173856
Buggy source:
private void displayMessage(String text){
  JOptionPane.showMessageDialog(this,text);
}

Fixed version (ground truth):
public void displayMessage(String text){
  JOptionPane.showMessageDialog(this,text);
}
Program: 173857
Project: 173857
Buggy source:
private void displayError(){
  JOptionPane.showMessageDialog(this,Log.getErrorBuffer());
}

Fixed version (ground truth):
public void displayError(){
  JOptionPane.showMessageDialog(this,Log.getErrorBuffer());
}
Program: 173858
Project: 173858
Buggy source:
public void processDone(){
  HexMap map=mapPanel.getMap();
  GUIHex selectedHex=map.getSelectedHex();
  setSubStep(INACTIVE);
  if (baseTokenLayingEnabled) {
    if (selectedHex != null) {
      if (selectedHex.getHexModel().getStations().size() == 1) {
        selectedHex.fixToken(0);
        map.selectHex(null);
      }
 else {
        Object[] stations=selectedHex.getHexModel().getStations().toArray();
        Station station=(Station)JOptionPane.showInputDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.PLAIN_MESSAGE,null,stations,stations[0]);
        try {
          selectedHex.fixToken(selectedHex.getHexModel().getStations().indexOf(station));
        }
 catch (        ArrayIndexOutOfBoundsException e) {
          Log.error("String_Node_Str");
        }
      }
    }
  }
 else {
    if (selectedHex != null) {
      selectedHex.fixTile(tileLayingEnabled);
      map.selectHex(null);
    }
  }
  updateUpgradePanel();
}

Fixed version (ground truth):
public void processDone(){
  HexMap map=mapPanel.getMap();
  GUIHex selectedHex=map.getSelectedHex();
  setSubStep(INACTIVE);
  if (baseTokenLayingEnabled) {
    if (selectedHex != null) {
      if (selectedHex.getHexModel().getStations().size() == 1) {
        selectedHex.fixToken(0);
        map.selectHex(null);
      }
 else {
        Object[] stations=selectedHex.getHexModel().getStations().toArray();
        Station station=(Station)JOptionPane.showInputDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.PLAIN_MESSAGE,null,stations,stations[0]);
        try {
          selectedHex.fixToken(selectedHex.getHexModel().getStations().indexOf(station));
        }
 catch (        ArrayIndexOutOfBoundsException e) {
          Log.error("String_Node_Str");
        }
      }
    }
  }
 else {
    if (selectedHex != null) {
      if (!selectedHex.fixTile(tileLayingEnabled)) {
        selectedHex.removeTile();
      }
      map.selectHex(null);
    }
  }
  updateUpgradePanel();
}
Program: 173859
Project: 173859
Buggy source:
public void fixTile(boolean tileLayingEnabled){
  if (tileLayingEnabled) {
    currentGUITile=provisionalGUITile;
    if (currentGUITile != null) {
      currentTile=currentGUITile.getTile();
      currentTileId=currentTile.getId();
      currentTileOrientation=provisionalTileOrientation;
    }
    GameUILoader.orWindow.getORPanel().layTile(model,currentTile,currentTileOrientation);
  }
  setSelected(false);
  setToolTip();
}

Fixed version (ground truth):
public boolean fixTile(boolean tileLayingEnabled){
  boolean canFixTile=true;
  if (tileLayingEnabled && provisionalGUITile != null) {
    OperatingRound or=(OperatingRound)GameManager.getInstance().getCurrentRound();
    canFixTile=or.layTile(or.getOperatingCompany().getName(),model,provisionalGUITile.getTile(),provisionalTileOrientation);
    if (canFixTile) {
      currentGUITile=provisionalGUITile;
      if (currentGUITile != null) {
        currentTile=currentGUITile.getTile();
        currentTileId=currentTile.getId();
        currentTileOrientation=provisionalTileOrientation;
      }
      GameUILoader.orWindow.getORPanel().layTile(model,currentTile,currentTileOrientation);
    }
 else {
      GameUILoader.orWindow.getORPanel().displayError();
    }
  }
  setSelected(false);
  setToolTip();
  return canFixTile;
}
Program: 173861
Project: 173861
Buggy source:
public void layBaseToken(MapHex hex,int station){
  if (!(round instanceof OperatingRound))   return;
  oRound=(OperatingRound)round;
  if (hex == null) {
    oRound.skip(orCompName);
  }
 else   if (oRound.layBaseToken(orCompName,hex,station)) {
    int cost=oRound.getLastBaseTokenLayCost();
    tokenCost[orCompIndex].setText(cost > 0 ? Bank.format(cost) : "String_Node_Str");
    tokens[orCompIndex].setText(oRound.getLastBaseTokenLaid());
  }
 else {
    displayError();
  }
  button3.setEnabled(true);
  LogWindow.addLog();
  if (oRound.getStep() != OperatingRound.STEP_LAY_TOKEN) {
    GameUILoader.orWindow.enableBaseTokenLaying(false);
    this.requestFocus();
  }
  updateStatus();
}

Fixed version (ground truth):
public void layBaseToken(MapHex hex,int station){
  if (!(round instanceof OperatingRound))   return;
  oRound=(OperatingRound)round;
  if (hex == null) {
    oRound.skip(orCompName);
  }
 else {
    int cost=oRound.getLastBaseTokenLayCost();
    tokenCost[orCompIndex].setText(cost > 0 ? Bank.format(cost) : "String_Node_Str");
    tokens[orCompIndex].setText(oRound.getLastBaseTokenLaid());
  }
  button3.setEnabled(true);
  LogWindow.addLog();
  if (oRound.getStep() != OperatingRound.STEP_LAY_TOKEN) {
    GameUILoader.orWindow.enableBaseTokenLaying(false);
    this.requestFocus();
  }
  updateStatus();
}
Program: 173862
Project: 173862
Buggy source:
public void processDone(){
  HexMap map=mapPanel.getMap();
  GUIHex selectedHex=map.getSelectedHex();
  setSubStep(INACTIVE);
  if (baseTokenLayingEnabled) {
    if (selectedHex != null) {
      if (selectedHex.getHexModel().getStations().size() == 1) {
        selectedHex.fixToken(0);
        map.selectHex(null);
      }
 else {
        Object[] stations=selectedHex.getHexModel().getStations().toArray();
        Station station=(Station)JOptionPane.showInputDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.PLAIN_MESSAGE,null,stations,stations[0]);
        try {
          selectedHex.fixToken(selectedHex.getHexModel().getStations().indexOf(station));
        }
 catch (        ArrayIndexOutOfBoundsException e) {
          Log.error("String_Node_Str");
        }
      }
    }
  }
 else {
    if (selectedHex != null) {
      if (!selectedHex.fixTile(tileLayingEnabled)) {
        selectedHex.removeTile();
      }
      map.selectHex(null);
    }
  }
  updateUpgradePanel();
}

Fixed version (ground truth):
public void processDone(){
  HexMap map=mapPanel.getMap();
  GUIHex selectedHex=map.getSelectedHex();
  if (baseTokenLayingEnabled) {
    if (selectedHex != null) {
      if (selectedHex.getHexModel().getStations().size() == 1) {
        if (selectedHex.fixToken(0)) {
        }
 else {
          setSubStep(SELECT_HEX_FOR_TOKEN);
        }
        map.selectHex(null);
      }
 else {
        Object[] stations=selectedHex.getHexModel().getStations().toArray();
        Station station=(Station)JOptionPane.showInputDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.PLAIN_MESSAGE,null,stations,stations[0]);
        try {
          if (selectedHex.fixToken(selectedHex.getHexModel().getStations().indexOf(station))) {
          }
 else {
            setSubStep(SELECT_HEX_FOR_TOKEN);
          }
        }
 catch (        ArrayIndexOutOfBoundsException e) {
          Log.error("String_Node_Str");
        }
      }
    }
  }
 else {
    if (selectedHex != null) {
      if (!selectedHex.fixTile(tileLayingEnabled)) {
        selectedHex.removeTile();
        setSubStep(SELECT_HEX_FOR_TILE);
      }
 else {
      }
      map.selectHex(null);
    }
  }
  updateUpgradePanel();
}
Program: 173863
Project: 173863
Buggy source:
public void fixToken(int station){
  GameUILoader.orWindow.getORPanel().layBaseToken(model,station);
  setSelected(false);
}

Fixed version (ground truth):
public boolean fixToken(int station){
  OperatingRound or=(OperatingRound)GameManager.getInstance().getCurrentRound();
  boolean canFixToken=or.layBaseToken(or.getOperatingCompany().getName(),model,station);
  if (canFixToken) {
    GameUILoader.orWindow.getORPanel().layBaseToken(model,station);
  }
 else {
    GameUILoader.orWindow.getORPanel().displayError();
  }
  setSelected(false);
  return canFixToken;
}
Program: 173864
Project: 173864
Buggy source:
public void mouseClicked(MouseEvent arg0){
  Point point=arg0.getPoint();
  GUIHex clickedHex=getHexContainingPoint(point);
  if (ORWindow.baseTokenLayingEnabled) {
    selectHex(clickedHex);
    if (selectedHex != null) {
      GameUILoader.orWindow.setSubStep(ORWindow.CONFIRM_TOKEN);
    }
 else {
      GameUILoader.orWindow.setSubStep(ORWindow.SELECT_HEX_FOR_TOKEN);
    }
  }
 else   if (ORWindow.tileLayingEnabled) {
    if (GameUILoader.orWindow.getSubStep() == ORWindow.ROTATE_OR_CONFIRM_TILE && clickedHex == selectedHex) {
      selectedHex.rotateTile();
      repaint(selectedHex.getBounds());
    }
 else {
      if (selectedHex != null && clickedHex != selectedHex) {
        selectedHex.removeTile();
        selectHex(null);
      }
      if (clickedHex != null) {
        if (clickedHex.getHexModel().isUpgradeableNow()) {
          selectHex(clickedHex);
          GameUILoader.orWindow.setSubStep(ORWindow.SELECT_TILE);
        }
 else {
          JOptionPane.showMessageDialog(this,"String_Node_Str");
        }
      }
    }
  }
  GameUILoader.orWindow.updateUpgradePanel();
  GameUILoader.orWindow.updateORPanel();
}

Fixed version (ground truth):
public void mouseClicked(MouseEvent arg0){
  Point point=arg0.getPoint();
  GUIHex clickedHex=getHexContainingPoint(point);
  if (ORWindow.baseTokenLayingEnabled) {
    selectHex(clickedHex);
    if (selectedHex != null) {
      GameUILoader.orWindow.setSubStep(ORWindow.CONFIRM_TOKEN);
    }
 else {
      GameUILoader.orWindow.setSubStep(ORWindow.SELECT_HEX_FOR_TOKEN);
    }
  }
 else   if (ORWindow.tileLayingEnabled) {
    if (GameUILoader.orWindow.getSubStep() == ORWindow.ROTATE_OR_CONFIRM_TILE && clickedHex == selectedHex) {
      selectedHex.rotateTile();
      repaint(selectedHex.getBounds());
      return;
    }
 else {
      if (selectedHex != null && clickedHex != selectedHex) {
        selectedHex.removeTile();
        selectHex(null);
      }
      if (clickedHex != null) {
        if (clickedHex.getHexModel().isUpgradeableNow()) {
          selectHex(clickedHex);
          GameUILoader.orWindow.setSubStep(ORWindow.SELECT_TILE);
        }
 else {
          JOptionPane.showMessageDialog(this,"String_Node_Str");
        }
      }
    }
  }
  GameUILoader.orWindow.updateUpgradePanel();
  GameUILoader.orWindow.updateORPanel();
}
Program: 173865
Project: 173865
Buggy source:
public void windowClosing(WindowEvent e){
  StatusWindow.uncheckMenuItemBox(StatusWindow.MAP);
  dispose();
}

Fixed version (ground truth):
public void windowClosing(WindowEvent e){
  StatusWindow.uncheckMenuItemBox(StatusWindow.MAP);
  parent.setOrWindow(null);
  dispose();
}
Program: 173866
Project: 173866
Buggy source:
public ORWindow(OperatingRound round,StatusWindow parent){
  super();
  getContentPane().setLayout(new BorderLayout());
  if (round != null) {
    mapPanel=GameUILoader.mapPanel;
    upgradePanel=new UpgradesPanel(mapPanel.getMap());
    getContentPane().add(upgradePanel,BorderLayout.WEST);
    mapPanel.setUpgradesPanel(upgradePanel);
    mapPanel.getMap().setUpgradesPanel(upgradePanel);
    ORPanel=new ORPanel(round,parent,this);
    getContentPane().add(ORPanel,BorderLayout.SOUTH);
    setSize(800,750);
  }
 else   if (OperatingRound.getLastORNumber() > 0) {
    mapPanel=GameUILoader.mapPanel;
    setSize(mapPanel.getSize());
    mapPanel.setVisible(true);
  }
 else {
    mapPanel=new MapPanel();
    setSize(mapPanel.getSize());
  }
  getContentPane().add(mapPanel,BorderLayout.CENTER);
  setTitle("String_Node_Str");
  setLocation(10,10);
  setVisible(true);
  addWindowListener(this);
  LogWindow.addLog();
}

Fixed version (ground truth):
public ORWindow(OperatingRound round,StatusWindow parent){
  super();
  getContentPane().setLayout(new BorderLayout());
  this.parent=parent;
  if (round != null) {
    mapPanel=GameUILoader.mapPanel;
    upgradePanel=new UpgradesPanel(mapPanel.getMap());
    getContentPane().add(upgradePanel,BorderLayout.WEST);
    mapPanel.setUpgradesPanel(upgradePanel);
    mapPanel.getMap().setUpgradesPanel(upgradePanel);
    ORPanel=new ORPanel(round,parent,this);
    getContentPane().add(ORPanel,BorderLayout.SOUTH);
    setSize(800,750);
  }
 else   if (OperatingRound.getLastORNumber() > 0) {
    mapPanel=GameUILoader.mapPanel;
    setSize(mapPanel.getSize());
    mapPanel.setVisible(true);
  }
 else {
    mapPanel=new MapPanel();
    setSize(mapPanel.getSize());
  }
  getContentPane().add(mapPanel,BorderLayout.CENTER);
  setTitle("String_Node_Str");
  setLocation(10,10);
  setVisible(true);
  addWindowListener(this);
  LogWindow.addLog();
}
Program: 173867
Project: 173867
Buggy source:
public void upgrade(TileI newTile,int newOrientation){
  if (currentTile != null)   currentTile.remove(this);
  newTile.lay(this);
  if (hasTokens)   moveTokens(newTile);
  currentTile=newTile;
  currentTileRotation=newOrientation;
}

Fixed version (ground truth):
public void upgrade(TileI newTile,int newOrientation){
  if (currentTile != null)   currentTile.remove(this);
  newTile.lay(this);
  moveTokens(newTile);
  currentTile=newTile;
  currentTileRotation=newOrientation;
}
Program: 173870
Project: 173870
Buggy source:
public StatusWindow(){
  cm=Game.getCompanyManager();
  companies=(PublicCompanyI[])cm.getAllPublicCompanies().toArray(new PublicCompanyI[0]);
  ipo=Bank.getIpo();
  pool=Bank.getPool();
  gameStatus=new GameStatus(this);
  buttonPanel=new JPanel();
  buyButton=new JButton("String_Node_Str");
  sellButton=new JButton("String_Node_Str");
  passButton=new JButton("String_Node_Str");
  buyButton.setMnemonic(KeyEvent.VK_B);
  sellButton.setMnemonic(KeyEvent.VK_S);
  passButton.setMnemonic(KeyEvent.VK_P);
  buttonPanel.add(buyButton);
  buttonPanel.add(sellButton);
  buttonPanel.add(passButton);
  buyButton.setActionCommand("String_Node_Str");
  sellButton.setActionCommand("String_Node_Str");
  passButton.setActionCommand("String_Node_Str");
  buyButton.addActionListener(this);
  sellButton.addActionListener(this);
  passButton.addActionListener(this);
  setSize(800,300);
  setLocation(25,450);
  buttonPanel.setBorder(BorderFactory.createEtchedBorder());
  buttonPanel.setOpaque(false);
  setTitle("String_Node_Str");
  pane.setLayout(new BorderLayout());
  init();
  initMenu();
  pane.add(gameStatus,BorderLayout.NORTH);
  pane.add(buttonPanel,BorderLayout.CENTER);
  pane.setOpaque(true);
  setContentPane(pane);
  refreshStatus();
  setVisible(true);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  gmgr=GameManager.getInstance();
  currentRound=gmgr.getCurrentRound();
  updateStatus();
  pack();
  gameStatus.addKeyListener(this);
  buttonPanel.addKeyListener(this);
  addKeyListener(this);
}

Fixed version (ground truth):
public StatusWindow(){
  cm=Game.getCompanyManager();
  companies=(PublicCompanyI[])cm.getAllPublicCompanies().toArray(new PublicCompanyI[0]);
  ipo=Bank.getIpo();
  pool=Bank.getPool();
  gameStatus=new GameStatus(this);
  buttonPanel=new JPanel();
  buyButton=new JButton(BUY);
  sellButton=new JButton(SELL);
  passButton=new JButton(PASS);
  buyButton.setMnemonic(KeyEvent.VK_B);
  sellButton.setMnemonic(KeyEvent.VK_S);
  passButton.setMnemonic(KeyEvent.VK_P);
  buttonPanel.add(buyButton);
  buttonPanel.add(sellButton);
  buttonPanel.add(passButton);
  buyButton.setActionCommand(BUY);
  sellButton.setActionCommand(SELL);
  passButton.setActionCommand(DONE);
  buyButton.addActionListener(this);
  sellButton.addActionListener(this);
  passButton.addActionListener(this);
  setSize(800,300);
  setLocation(25,450);
  buttonPanel.setBorder(BorderFactory.createEtchedBorder());
  buttonPanel.setOpaque(false);
  setTitle("String_Node_Str");
  pane.setLayout(new BorderLayout());
  init();
  initMenu();
  pane.add(gameStatus,BorderLayout.NORTH);
  pane.add(buttonPanel,BorderLayout.CENTER);
  pane.setOpaque(true);
  setContentPane(pane);
  refreshStatus();
  setVisible(true);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  gmgr=GameManager.getInstance();
  currentRound=gmgr.getCurrentRound();
  updateStatus();
  pack();
  gameStatus.addKeyListener(this);
  buttonPanel.addKeyListener(this);
  addKeyListener(this);
}
Program: 173871
Project: 173871
Buggy source:
public void updateStatus(){
  if (currentRound instanceof StartRound) {
    passButton.setEnabled(false);
    startRound=(StartRound)currentRound;
    if (startRoundWindow == null)     startRoundWindow=new StartRoundWindow(startRound,this);
    startRoundWindow.setSRPlayerTurn(startRound.getCurrentPlayerIndex());
    GameUILoader.stockChart.setVisible(false);
    GameUILoader.mapPanel.setVisible(false);
  }
 else   if (currentRound instanceof StockRound) {
    passButton.setEnabled(true);
    stockRound=(StockRound)currentRound;
    gameStatus.setSRPlayerTurn(GameManager.getCurrentPlayerIndex());
    GameUILoader.stockChart.setVisible(true);
    GameUILoader.mapPanel.setVisible(false);
    enableCheckBoxMenuItem("String_Node_Str");
    disableCheckBoxMenuItem("String_Node_Str");
    refreshStatus();
    toFront();
  }
 else   if (currentRound instanceof OperatingRound) {
    passButton.setEnabled(false);
    operatingRound=(OperatingRound)currentRound;
    if (orWindow == null)     orWindow=new ORWindow(operatingRound,this);
    GameUILoader.stockChart.setVisible(false);
    GameUILoader.mapPanel.setVisible(true);
    orWindow.requestFocus();
    enableCheckBoxMenuItem("String_Node_Str");
    disableCheckBoxMenuItem("String_Node_Str");
  }
}

Fixed version (ground truth):
public void updateStatus(){
  if (currentRound instanceof StartRound) {
    passButton.setEnabled(false);
    startRound=(StartRound)currentRound;
    if (startRoundWindow == null)     startRoundWindow=new StartRoundWindow(startRound,this);
    startRoundWindow.setSRPlayerTurn(startRound.getCurrentPlayerIndex());
    GameUILoader.stockChart.setVisible(false);
    GameUILoader.mapPanel.setVisible(false);
    disableCheckBoxMenuItem(MAP);
    disableCheckBoxMenuItem(MARKET);
  }
 else   if (currentRound instanceof StockRound) {
    passButton.setEnabled(true);
    stockRound=(StockRound)currentRound;
    gameStatus.setSRPlayerTurn(GameManager.getCurrentPlayerIndex());
    GameUILoader.stockChart.setVisible(true);
    GameUILoader.mapPanel.setVisible(false);
    enableCheckBoxMenuItem(MARKET);
    disableCheckBoxMenuItem(MAP);
    refreshStatus();
    toFront();
  }
 else   if (currentRound instanceof OperatingRound) {
    passButton.setEnabled(false);
    operatingRound=(OperatingRound)currentRound;
    if (orWindow == null)     orWindow=new ORWindow(operatingRound,this);
    GameUILoader.stockChart.setVisible(false);
    GameUILoader.mapPanel.setVisible(true);
    orWindow.requestFocus();
    enableCheckBoxMenuItem(MAP);
    disableCheckBoxMenuItem(MARKET);
  }
}
Program: 173872
Project: 173872
Buggy source:
public MapPanel(){
  Scale.set(15);
  setLayout(new BorderLayout());
  mmgr=MapManager.getInstance();
  try {
    map=(HexMap)Class.forName(mmgr.getMapUIClassName()).newInstance();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
    return;
  }
  addMouseListener(map);
  addMouseMotionListener(map);
  ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
  scrollPane=new JScrollPane(map);
  scrollPane.setSize(map.getPreferredSize());
  scrollPane.addMouseListener(map);
  add(scrollPane,BorderLayout.CENTER);
  setSize(map.getPreferredSize().width,map.getPreferredSize().height);
  setLocation(25,25);
}

Fixed version (ground truth):
public MapPanel(){
  Scale.set(15);
  setLayout(new BorderLayout());
  mmgr=MapManager.getInstance();
  try {
    map=(HexMap)Class.forName(mmgr.getMapUIClassName()).newInstance();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
    return;
  }
  addMouseListener(map);
  addMouseMotionListener(map);
  ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
  scrollPane=new JScrollPane(map);
  scrollPane.setSize(map.getPreferredSize());
  scrollPane.getViewport().addMouseListener(map);
  add(scrollPane,BorderLayout.CENTER);
  setSize(map.getPreferredSize().width,map.getPreferredSize().height);
  setLocation(25,25);
}
Program: 173873
Project: 173873
Buggy source:
public void configureFromXML(Element el) throws ConfigurationException {
  NamedNodeMap attributes;
  String colourList;
  String[] colourArray=new String[0];
  tileColours=new HashMap();
  NodeList nl=el.getElementsByTagName("String_Node_Str");
  if (nl != null && nl.getLength() > 0) {
    attributes=nl.item(0).getAttributes();
    colourList=XmlUtils.extractStringAttribute(attributes,"String_Node_Str");
    if (colourList != null)     colourArray=colourList.split("String_Node_Str");
    for (int i=0; i < colourArray.length; i++) {
      tileColours.put(colourArray[i],null);
    }
  }
  nl=el.getElementsByTagName("String_Node_Str");
  if (nl != null && nl.getLength() > 0) {
    attributes=nl.item(0).getAttributes();
    privateSellingAllowed=previousPrivateSellingAllowed=XmlUtils.extractBooleanAttribute(attributes,"String_Node_Str",previousPrivateSellingAllowed);
    privatesClose=XmlUtils.extractBooleanAttribute(attributes,"String_Node_Str",false);
  }
  nl=el.getElementsByTagName("String_Node_Str");
  if (nl != null && nl.getLength() > 0) {
    attributes=nl.item(0).getAttributes();
    numberOfOperatingRounds=previousNumberOfOperatingRounds=XmlUtils.extractIntegerAttribute(attributes,"String_Node_Str",previousNumberOfOperatingRounds);
  }
}

Fixed version (ground truth):
public void configureFromXML(Element el) throws ConfigurationException {
  NamedNodeMap attributes;
  String colourList;
  String[] colourArray=new String[0];
  tileColours=new HashMap();
  NodeList nl=el.getElementsByTagName("String_Node_Str");
  if (nl != null && nl.getLength() > 0) {
    attributes=nl.item(0).getAttributes();
    colourList=XmlUtils.extractStringAttribute(attributes,"String_Node_Str",previousTileColours);
  }
 else {
    colourList=previousTileColours;
  }
  if (colourList != null)   colourArray=colourList.split("String_Node_Str");
  for (int i=0; i < colourArray.length; i++) {
    tileColours.put(colourArray[i],null);
  }
  nl=el.getElementsByTagName("String_Node_Str");
  if (nl != null && nl.getLength() > 0) {
    attributes=nl.item(0).getAttributes();
    privateSellingAllowed=previousPrivateSellingAllowed=XmlUtils.extractBooleanAttribute(attributes,"String_Node_Str",previousPrivateSellingAllowed);
    privatesClose=XmlUtils.extractBooleanAttribute(attributes,"String_Node_Str",false);
  }
 else {
    privateSellingAllowed=previousPrivateSellingAllowed;
  }
  nl=el.getElementsByTagName("String_Node_Str");
  if (nl != null && nl.getLength() > 0) {
    attributes=nl.item(0).getAttributes();
    numberOfOperatingRounds=previousNumberOfOperatingRounds=XmlUtils.extractIntegerAttribute(attributes,"String_Node_Str",previousNumberOfOperatingRounds);
  }
 else {
    numberOfOperatingRounds=previousNumberOfOperatingRounds;
  }
  System.out.println("String_Node_Str" + index + "String_Node_Str"+ name+ "String_Node_Str"+ numberOfOperatingRounds+ "String_Node_Str");
}
Program: 173874
Project: 173874
Buggy source:
/** 
 * A (perhaps temporary) method via which the cost of station token laying can be accounted for.
 * @param companyName The name of the company that lays the token.
 * @param amountSpent The cost of laying the token, which is subtracted from the company treasury.
 * @return
 */
public boolean layBaseToken(String companyName,MapHex hex,int station){
  String errMsg=null;
  int cost=0;
  while (true) {
    if (!companyName.equals(operatingCompany.getName())) {
      errMsg="String_Node_Str" + companyName;
      break;
    }
    if (step != STEP_LAY_TOKEN) {
      errMsg="String_Node_Str";
      break;
    }
    if (!operatingCompany.hasTokens()) {
      errMsg="String_Node_Str";
      break;
    }
    cost=Game.getCompanyManager().getBaseTokenLayCostBySequence(operatingCompany.getNextBaseTokenIndex());
    if (cost > operatingCompany.getCash()) {
      errMsg="String_Node_Str";
      break;
    }
    break;
  }
  if (errMsg != null) {
    Log.error("String_Node_Str" + hex.getName() + "String_Node_Str"+ Bank.format(cost)+ "String_Node_Str"+ errMsg);
    return false;
  }
  if (!operatingCompany.layBaseToken(hex))   return false;
  lastBaseTokenLaid=hex.getName();
  lastBaseTokenLayCost=cost;
  if (cost > 0) {
    Bank.transferCash((CashHolder)operatingCompany,null,cost);
    Log.write(companyName + "String_Node_Str" + hex.getName()+ "String_Node_Str"+ Bank.format(cost));
  }
 else {
    Log.write(companyName + "String_Node_Str" + hex.getName());
  }
  nextStep(operatingCompany);
  return true;
}

Fixed version (ground truth):
/** 
 * A (perhaps temporary) method via which the cost of station token laying can be accounted for.
 * @param companyName The name of the company that lays the token.
 * @param amountSpent The cost of laying the token, which is subtracted from the company treasury.
 * @return
 */
public boolean layBaseToken(String companyName,MapHex hex,int station){
  String errMsg=null;
  int cost=0;
  while (true) {
    if (!companyName.equals(operatingCompany.getName())) {
      errMsg="String_Node_Str" + companyName;
      break;
    }
    if (step != STEP_LAY_TOKEN) {
      errMsg="String_Node_Str";
      break;
    }
    if (!operatingCompany.hasTokens()) {
      errMsg="String_Node_Str";
      break;
    }
    cost=Game.getCompanyManager().getBaseTokenLayCostBySequence(operatingCompany.getNextBaseTokenIndex());
    if (cost > operatingCompany.getCash()) {
      errMsg="String_Node_Str";
      break;
    }
    break;
  }
  if (errMsg != null) {
    Log.error("String_Node_Str" + hex.getName() + "String_Node_Str"+ Bank.format(cost)+ "String_Node_Str"+ errMsg);
    return false;
  }
  if (!operatingCompany.layBaseToken(hex,station))   return false;
  lastBaseTokenLaid=hex.getName();
  lastBaseTokenLayCost=cost;
  if (cost > 0) {
    Bank.transferCash((CashHolder)operatingCompany,null,cost);
    Log.write(companyName + "String_Node_Str" + hex.getName()+ "String_Node_Str"+ Bank.format(cost));
  }
 else {
    Log.write(companyName + "String_Node_Str" + hex.getName());
  }
  nextStep(operatingCompany);
  return true;
}
Program: 173875
Project: 173875
Buggy source:
public boolean layBaseToken(MapHex hex){
  return hex.addToken(this,0);
}

Fixed version (ground truth):
public boolean layBaseToken(MapHex hex,int station){
  return hex.addToken(this,station);
}
Program: 173876
Project: 173876
Buggy source:
public boolean layBaseToken(MapHex hex);

Fixed version (ground truth):
public boolean layBaseToken(MapHex hex,int station);
Program: 173877
Project: 173877
Buggy source:
private Point getTokenOrigin(int numTokens,int currentToken,int numStations,int currentStation){
  Point p=new Point();
switch (numStations) {
case 1:
switch (numTokens) {
case 1:
      p.x=(center.x - 9);
    p.y=(center.y - 9);
  return p;
case 2:
if (currentToken == 0) {
  p.x=(center.x - 5);
  p.y=(center.y - 9);
  return p;
}
 else {
  p.x=(center.x - 17);
  p.y=(center.y - 9);
  return p;
}
case 3:
if (currentToken == 0) {
p.x=(center.x - 14);
p.y=(center.y - 3);
return p;
}
 else if (currentToken == 1) {
p.x=(center.x - 5);
p.y=(center.y - 3);
return p;
}
 else {
p.x=(center.x - 9);
p.y=(center.y - 14);
return p;
}
case 4:
case 5:
case 6:
default :
return center;
}
case 2:
if (currentStation == 0) {
switch (numTokens) {
case 1:
p.x=(center.x - 14);
p.y=(center.y + 3);
return p;
case 2:
if (currentToken == 0) {
p.x=(center.x - 14);
p.y=(center.y + 3);
return p;
}
 else {
p.x=(center.x - 20);
p.y=(center.y + 12);
return p;
}
default :
return center;
}
}
 else {
switch (numTokens) {
case 1:
p.x=(center.x - 1);
p.y=(center.y - 20);
return p;
case 2:
if (currentToken == 0) {
p.x=(center.x - 1);
p.y=(center.y - 20);
return p;
}
 else {
p.x=(center.x - 6);
p.y=(center.y - 8);
return p;
}
default :
return center;
}
}
case 3:
default :
return center;
}
}

Fixed version (ground truth):
private Point getTokenOrigin(int numTokens,int currentToken,int numStations,int currentStation){
  Point p=new Point();
switch (numStations) {
case 1:
switch (numTokens) {
case 1:
      p.x=(center.x - 9);
    p.y=(center.y - 9);
  return p;
case 2:
if (currentToken == 0) {
  p.x=(center.x - 5);
  p.y=(center.y - 9);
  return p;
}
 else {
  p.x=(center.x - 17);
  p.y=(center.y - 9);
  return p;
}
case 3:
if (currentToken == 0) {
p.x=(center.x - 14);
p.y=(center.y - 3);
return p;
}
 else if (currentToken == 1) {
p.x=(center.x - 5);
p.y=(center.y - 3);
return p;
}
 else {
p.x=(center.x - 9);
p.y=(center.y - 14);
return p;
}
case 4:
case 5:
case 6:
default :
return center;
}
case 2:
if (currentStation == 0) {
switch (numTokens) {
case 1:
p.x=(center.x - 14);
p.y=(center.y + 3);
return p;
case 2:
if (currentToken == 0) {
p.x=(center.x - 20);
p.y=(center.y - 3);
return p;
}
 else {
p.x=(center.x - 10);
p.y=(center.y + 9);
return p;
}
default :
return center;
}
}
 else {
switch (numTokens) {
case 1:
p.x=(center.x - 1);
p.y=(center.y - 20);
return p;
case 2:
if (currentToken == 0) {
p.x=(center.x - 6);
p.y=(center.y - 23);
return p;
}
 else {
p.x=(center.x + 6);
p.y=(center.y - 12);
return p;
}
default :
return center;
}
}
case 3:
default :
return center;
}
}
Program: 173878
Project: 173878
Buggy source:
public void processDone(){
  if (baseTokenLayingEnabled) {
    if (selectedHex != null) {
      if (selectedHex.getHexModel().getStations().size() == 1)       selectedHex.fixToken(1);
 else {
        Object[] stations=selectedHex.getHexModel().getStations().toArray();
        Station station=(Station)JOptionPane.showInputDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.PLAIN_MESSAGE,null,stations,stations[0]);
        selectedHex.fixToken(selectedHex.getHexModel().getStations().indexOf(station));
      }
    }
  }
 else {
    if (selectedHex != null)     selectedHex.fixTile(tileLayingEnabled);
  }
}

Fixed version (ground truth):
public void processDone(){
  if (baseTokenLayingEnabled) {
    if (selectedHex != null) {
      if (selectedHex.getHexModel().getStations().size() == 1)       selectedHex.fixToken(0);
 else {
        Object[] stations=selectedHex.getHexModel().getStations().toArray();
        Station station=(Station)JOptionPane.showInputDialog(this,"String_Node_Str","String_Node_Str",JOptionPane.PLAIN_MESSAGE,null,stations,stations[0]);
        selectedHex.fixToken(selectedHex.getHexModel().getStations().indexOf(station));
      }
    }
  }
 else {
    if (selectedHex != null)     selectedHex.fixTile(tileLayingEnabled);
  }
}
Program: 173879
Project: 173879
Buggy source:
public int getTrainLimit(int phaseIndex){
  if (phaseIndex > trainLimit.length) {
    return trainLimit[trainLimit.length - 1];
  }
 else {
    return trainLimit[phaseIndex];
  }
}

Fixed version (ground truth):
public int getTrainLimit(int phaseIndex){
  return trainLimit[Math.min(phaseIndex,trainLimit.length - 1)];
}
Program: 173880
Project: 173880
Buggy source:
/** 
 * Add it to the error buffer 
 */
public static void error(String message){
  if (XmlUtils.hasValue(message)) {
    System.out.println(message);
    errorBuffer.append(message);
  }
}

Fixed version (ground truth):
/** 
 * Add it to the error buffer 
 */
public static void error(String message){
  if (Utils.hasValue(message)) {
    System.out.println(message);
    errorBuffer.append(message);
  }
}
Program: 173881
Project: 173881
Buggy source:
/** 
 * Log a message, and add it to the display buffer 
 */
public static void write(String message){
  if (XmlUtils.hasValue(message)) {
    System.out.println(message);
    messageBuffer.append(message).append("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Log a message, and add it to the display buffer 
 */
public static void write(String message){
  if (Utils.hasValue(message)) {
    System.out.println(message);
    messageBuffer.append(message).append("String_Node_Str");
  }
}
Program: 173882
Project: 173882
Buggy source:
public MapPanel(){
  Scale.set(15);
  setLayout(new BorderLayout());
  mmgr=MapManager.getInstance();
  try {
    map=(HexMap)Class.forName(mmgr.getMapUIClassName()).newInstance();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
    return;
  }
  addMouseListener(map);
  addMouseMotionListener(map);
  ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
  scrollPane=new JScrollPane(map);
  scrollPane.setSize(map.getPreferredSize());
  scrollPane.getViewport().addMouseListener(map);
  add(scrollPane,BorderLayout.CENTER);
  setSize(map.getPreferredSize().width,map.getPreferredSize().height);
  setLocation(25,25);
}

Fixed version (ground truth):
public MapPanel(){
  Scale.set(15);
  setLayout(new BorderLayout());
  mmgr=MapManager.getInstance();
  try {
    map=(HexMap)Class.forName(mmgr.getMapUIClassName()).newInstance();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
    return;
  }
  ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
  scrollPane=new JScrollPane(map);
  scrollPane.setSize(map.getPreferredSize());
  add(scrollPane,BorderLayout.CENTER);
  setSize(map.getPreferredSize().width,map.getPreferredSize().height);
  setLocation(25,25);
}
Program: 173883
Project: 173883
Buggy source:
public ORWindow(){
  super();
  getContentPane().setLayout(new BorderLayout());
  messagePanel=new MessagePanel();
  getContentPane().add(messagePanel,BorderLayout.NORTH);
  if (mapPanel == null)   mapPanel=new MapPanel();
 else   mapPanel=GameUILoader.getMapPanel();
  getContentPane().add(mapPanel,BorderLayout.CENTER);
  addMouseListener(mapPanel.getMap());
  upgradePanel=new UpgradesPanel();
  getContentPane().add(upgradePanel,BorderLayout.WEST);
  addMouseListener(upgradePanel);
  ORPanel=new ORPanel();
  getContentPane().add(ORPanel,BorderLayout.SOUTH);
  setTitle("String_Node_Str");
  setLocation(10,10);
  setVisible(true);
  setSize(800,600);
  addWindowListener(this);
  LogWindow.addLog();
}

Fixed version (ground truth):
public ORWindow(){
  super();
  getContentPane().setLayout(new BorderLayout());
  messagePanel=new MessagePanel();
  getContentPane().add(messagePanel,BorderLayout.NORTH);
  if (mapPanel == null)   mapPanel=new MapPanel();
 else   mapPanel=GameUILoader.getMapPanel();
  getContentPane().add(mapPanel,BorderLayout.CENTER);
  upgradePanel=new UpgradesPanel();
  getContentPane().add(upgradePanel,BorderLayout.WEST);
  addMouseListener(upgradePanel);
  ORPanel=new ORPanel();
  getContentPane().add(ORPanel,BorderLayout.SOUTH);
  setTitle("String_Node_Str");
  setLocation(10,10);
  setVisible(true);
  setSize(800,600);
  addWindowListener(this);
  LogWindow.addLog();
}
Program: 173884
Project: 173884
Buggy source:
public void setupHexes(){
  setupHexesGUI();
}

Fixed version (ground truth):
public void setupHexes(){
  setupHexesGUI();
  addMouseListener(this);
  addMouseMotionListener(this);
}
Program: 173885
Project: 173885
Buggy source:
private void playHomeTokens(){
  PublicCompanyI[] companies=(PublicCompanyI[])Game.getCompanyManager().getAllPublicCompanies().toArray(new PublicCompanyI[0]);
  for (int compIndex=0; compIndex < companies.length; compIndex++) {
    System.out.println(companies[compIndex]);
    if (companies[compIndex].hasFloated() && companies[compIndex].hasStarted()) {
      MapHex[][] map=MapManager.getInstance().getHexes();
      for (int i=0; i < map.length; i++) {
        for (int j=0; j < map[i].length; j++) {
          if (((PublicCompany)companies[compIndex]).getMaxCityTokens() == ((PublicCompany)companies[compIndex]).getNumCityTokens()) {
            try {
              if (map[i][j].getCompanyHome().equals(companies[compIndex])) {
                if (map[i][j].getPreferredHomeCity() > 0)                 map[i][j].addToken(companies[compIndex],map[i][j].getPreferredHomeCity() - 1);
 else                 map[i][j].addToken(companies[compIndex]);
              }
            }
 catch (            NullPointerException e) {
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void playHomeTokens(){
  PublicCompanyI[] companies=(PublicCompanyI[])Game.getCompanyManager().getAllPublicCompanies().toArray(new PublicCompanyI[0]);
  for (int compIndex=0; compIndex < companies.length; compIndex++) {
    if (companies[compIndex].hasFloated() && companies[compIndex].hasStarted()) {
      MapHex[][] map=MapManager.getInstance().getHexes();
      for (int i=0; i < map.length; i++) {
        for (int j=0; j < map[i].length; j++) {
          if (((PublicCompany)companies[compIndex]).getMaxCityTokens() == ((PublicCompany)companies[compIndex]).getNumCityTokens()) {
            try {
              if (map[i][j].getCompanyHome().equals(companies[compIndex])) {
                if (map[i][j].getPreferredHomeCity() > 0)                 map[i][j].addToken(companies[compIndex],map[i][j].getPreferredHomeCity() - 1);
 else                 map[i][j].addToken(companies[compIndex]);
              }
            }
 catch (            NullPointerException e) {
            }
          }
        }
      }
    }
  }
}
Program: 173886
Project: 173886
Buggy source:
private void paintToken(Graphics2D g2){
  if (getHexModel().getStations().size() > 1) {
    paintSplitStations(g2);
    return;
  }
  int numTokens=getHexModel().getTokens(0).size();
  ArrayList tokens=(ArrayList)getHexModel().getTokens(0);
  for (int i=0; i < tokens.size(); i++) {
    PublicCompany co=(PublicCompany)tokens.get(i);
    Point origin=getTokenOrigin(numTokens,i);
    drawToken(g2,co,origin);
  }
}

Fixed version (ground truth):
private void paintToken(Graphics2D g2){
  if (getHexModel().getStations().size() > 1) {
    paintSplitStations(g2);
    return;
  }
  int numTokens=getHexModel().getTokens(0).size();
  ArrayList tokens=(ArrayList)getHexModel().getTokens(0);
  for (int i=0; i < tokens.size(); i++) {
    PublicCompany co=(PublicCompany)tokens.get(i);
    Point origin=getTokenOrigin(numTokens,i,1,0);
    drawToken(g2,co,origin);
  }
}
Program: 173887
Project: 173887
Buggy source:
private void paintSplitStations(Graphics2D g2){
  int numStations=getHexModel().getStations().size();
  for (int i=0; i < numStations; i++) {
    int numTokens=getHexModel().getTokens(i).size();
    ArrayList tokens=(ArrayList)getHexModel().getTokens(i);
    Point origin=getTokenOrigin(numTokens,i);
    for (int j=0; j < tokens.size(); j++) {
      PublicCompany co=(PublicCompany)tokens.get(j);
switch (numStations) {
case 2:
switch (i) {
case 0:
          origin.y+=-5;
case 1:
        origin.y+=5;
default :
      break;
  }
case 3:
switch (i) {
case 0:
case 1:
case 2:
default :
  break;
}
default :
break;
}
drawToken(g2,co,origin);
}
}
}

Fixed version (ground truth):
private void paintSplitStations(Graphics2D g2){
  int numStations=getHexModel().getStations().size();
  int numTokens;
  ArrayList tokens;
  Point origin;
  PublicCompany co;
  for (int i=0; i < numStations; i++) {
    numTokens=getHexModel().getTokens(i).size();
    tokens=(ArrayList)getHexModel().getTokens(i);
    for (int j=0; j < tokens.size(); j++) {
      origin=getTokenOrigin(numTokens,j,numStations,i);
      co=(PublicCompany)tokens.get(j);
      drawToken(g2,co,origin);
    }
  }
}
Program: 173888
Project: 173888
Buggy source:
private Point getTokenOrigin(int numTokens,int currentToken){
  Point p;
switch (numTokens) {
case 1:
    p=findCenter();
  p.x+=-9;
p.y+=-9;
return p;
case 2:
if (currentToken == 0) {
p=findCenter();
p.x+=-14;
p.y+=-9;
return p;
}
 else {
p=findCenter();
p.x+=-4;
p.y+=-9;
return p;
}
case 3:
case 4:
case 5:
case 6:
default :
return findCenter();
}
}

Fixed version (ground truth):
private Point getTokenOrigin(int numTokens,int currentToken,int numStations,int currentStation){
  Point c=findCenter();
  Point p=new Point();
switch (numStations) {
case 1:
switch (numTokens) {
case 1:
      p.x=(c.x - 9);
    p.y=(c.y - 9);
  return p;
default :
return findCenter();
}
case 2:
if (currentStation == 0) {
switch (numTokens) {
case 1:
p.x=(c.x - 14);
p.y=(c.y + 3);
return p;
default :
return findCenter();
}
}
 else {
switch (numTokens) {
case 1:
p.x=(c.x - 1);
p.y=(c.y - 20);
return p;
default :
return findCenter();
}
}
case 3:
default :
return findCenter();
}
}
Program: 173889
Project: 173889
Buggy source:
public void init(String name,CompanyTypeI type){
  this.name=name;
  this.type=type;
}

Fixed version (ground truth):
public void init(String name,CompanyTypeI type){
  this.name=name;
  this.type=type;
  this.tokens=new ArrayList();
}