nus-yam/ex-repair huggingface dataset:
Program: 173501
Project: 173501
Buggy source:
/** 
 * Deserialize 
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  Company company;
  in.defaultReadObject();
  CompanyManager cmgr=getCompanyManager();
  if (foldableCompanyNames != null) {
    foldableCompanies=new ArrayList<Company>();
    for (    String name : foldableCompanyNames.split("String_Node_Str")) {
      foldableCompanies.add(cmgr.getPublicCompany(name));
    }
  }
  if (Util.hasValue(foldedCompanyNames)) {
    foldedCompanies=new ArrayList<Company>();
    for (    String name : foldedCompanyNames.split("String_Node_Str")) {
      company=cmgr.getPublicCompany(name);
      if (company == null)       company=cmgr.getPrivateCompany(name);
      if (company != null)       foldedCompanies.add(company);
    }
  }
}

Fixed version (ground truth):
/** 
 * Deserialize 
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  Company company;
  in.defaultReadObject();
  CompanyManager cmgr=getCompanyManager();
  if (foldableCompanyNames != null) {
    foldableCompanies=new ArrayList<Company>();
    for (    String name : foldableCompanyNames.split("String_Node_Str")) {
      company=cmgr.getPublicCompany(name);
      if (company == null)       company=cmgr.getPrivateCompany(name);
      if (company != null)       foldableCompanies.add(company);
    }
  }
  if (Util.hasValue(foldedCompanyNames)) {
    foldedCompanies=new ArrayList<Company>();
    for (    String name : foldedCompanyNames.split("String_Node_Str")) {
      company=cmgr.getPublicCompany(name);
      if (company == null)       company=cmgr.getPrivateCompany(name);
      if (company != null)       foldedCompanies.add(company);
    }
  }
}
Program: 173502
Project: 173502
Buggy source:
public void startPrussianFormationRound(OperatingRound_1835 or){
  interruptedRound=or;
  createRound(PrussianFormationRound.class,"String_Node_Str").start();
}

Fixed version (ground truth):
public void startPrussianFormationRound(OperatingRound_1835 or){
  interruptedRound=or;
  String roundName;
  if (interruptedRound == null) {
    roundName="String_Node_Str" + previousRound.getId();
  }
 else {
    roundName="String_Node_Str" + or.getId();
  }
  createRound(PrussianFormationRound.class,roundName).start();
}
Program: 173503
Project: 173503
Buggy source:
private void executeStartPrussian(boolean display){
  prussian.start();
  String message=LocalText.getText("String_Node_Str",PR_ID,Currency.format(this,prussian.getIPOPrice()),prussian.getStartSpace());
  ReportBuffer.add(message);
  if (display)   DisplayBuffer.add(message);
  int capFactor=getSoldPercentage(prussian) / (prussian.getShareUnit() * prussian.getShareUnitsForSharePrice());
  int cash=capFactor * prussian.getIPOPrice();
  if (cash > 0) {
    String cashText=Currency.fromBank(cash,prussian);
    ReportBuffer.add(LocalText.getText("String_Node_Str",prussian.getId(),cashText));
  }
 else {
    ReportBuffer.add(LocalText.getText("String_Node_Str",prussian.getId()));
  }
  executeExchange(Arrays.asList(new Company[]{m2}),true,false);
  prussian.setFloated();
}

Fixed version (ground truth):
private void executeStartPrussian(boolean display){
  prussian.start();
  String message=LocalText.getText("String_Node_Str",PR_ID,Currency.format(this,prussian.getIPOPrice()),prussian.getStartSpace().toText());
  ReportBuffer.add(message);
  if (display)   DisplayBuffer.add(message);
  int capFactor=getSoldPercentage(prussian) / (prussian.getShareUnit() * prussian.getShareUnitsForSharePrice());
  int cash=capFactor * prussian.getIPOPrice();
  if (cash > 0) {
    String cashText=Currency.fromBank(cash,prussian);
    ReportBuffer.add(LocalText.getText("String_Node_Str",prussian.getId(),cashText));
  }
 else {
    ReportBuffer.add(LocalText.getText("String_Node_Str",prussian.getId()));
  }
  executeExchange(Arrays.asList(new Company[]{m2}),true,false);
  prussian.setFloated();
}
Program: 173505
Project: 173505
Buggy source:
public void configureFromXML(Tag tag) throws ConfigurationException {
  String trainClassName=tag.getAttributeAsString("String_Node_Str",DEFAULT_TRAIN_CLASS);
  trainClass=Configure.getClassForName(Train.class,trainClassName);
  quantity=tag.getAttributeAsInteger("String_Node_Str",quantity);
  quantity+=tag.getAttributeAsInteger("String_Node_Str",0);
  initialPortfolio=tag.getAttributeAsString("String_Node_Str",initialPortfolio);
  List<Tag> newPhaseTags=tag.getChildren("String_Node_Str");
  if (newPhaseTags != null) {
    int index;
    String phaseName;
    newPhaseNames=new HashMap<Integer,String>();
    for (    Tag newPhaseTag : newPhaseTags) {
      phaseName=newPhaseTag.getAttributeAsString("String_Node_Str");
      if (!Util.hasValue(phaseName)) {
        throw new ConfigurationException("String_Node_Str" + getId() + "String_Node_Str");
      }
      index=newPhaseTag.getAttributeAsInteger("String_Node_Str",1);
      newPhaseNames.put(index,phaseName);
    }
  }
  Tag swapTag=tag.getChild("String_Node_Str");
  if (swapTag != null) {
    exchangeCost=swapTag.getAttributeAsInteger("String_Node_Str",0);
    canBeExchanged=(exchangeCost > 0);
  }
  obsoleting=tag.getAttributeAsBoolean("String_Node_Str");
}

Fixed version (ground truth):
public void configureFromXML(Tag tag) throws ConfigurationException {
  trainClassName=tag.getAttributeAsString("String_Node_Str",trainClassName);
  trainClass=Configure.getClassForName(Train.class,trainClassName);
  quantity=tag.getAttributeAsInteger("String_Node_Str",quantity);
  quantity+=tag.getAttributeAsInteger("String_Node_Str",0);
  initialPortfolio=tag.getAttributeAsString("String_Node_Str",initialPortfolio);
  List<Tag> newPhaseTags=tag.getChildren("String_Node_Str");
  if (newPhaseTags != null) {
    int index;
    String phaseName;
    newPhaseNames=new HashMap<Integer,String>();
    for (    Tag newPhaseTag : newPhaseTags) {
      phaseName=newPhaseTag.getAttributeAsString("String_Node_Str");
      if (!Util.hasValue(phaseName)) {
        throw new ConfigurationException("String_Node_Str" + getId() + "String_Node_Str");
      }
      index=newPhaseTag.getAttributeAsInteger("String_Node_Str",1);
      newPhaseNames.put(index,phaseName);
    }
  }
  Tag swapTag=tag.getChild("String_Node_Str");
  if (swapTag != null) {
    exchangeCost=swapTag.getAttributeAsInteger("String_Node_Str",0);
    canBeExchanged=(exchangeCost > 0);
  }
  obsoleting=tag.getAttributeAsBoolean("String_Node_Str");
}
Program: 173506
Project: 173506
Buggy source:
@Override public void configureFromXML(Tag tag) throws ConfigurationException {
  super.configureFromXML(tag);
  Tag assignTag=tag.getChild("String_Node_Str");
  if (assignTag == null) {
    throw new ConfigurationException("String_Node_Str");
  }
  tokenClassName=assignTag.getAttributeAsString("String_Node_Str");
  if (tokenClassName == null) {
    throw new ConfigurationException("String_Node_Str");
  }
  try {
    tokenClass=Class.forName(tokenClassName);
  }
 catch (  ClassNotFoundException e) {
    throw new ConfigurationException("String_Node_Str" + tokenClassName,e);
  }
  String tokenTagName=tokenClassName.replaceAll("String_Node_Str","String_Node_Str");
  List<Tag> tokenTags=assignTag.getChildren(tokenTagName);
  if (tokenTags == null || tokenTags.isEmpty()) {
    throw new ConfigurationException("String_Node_Str" + tokenTagName + "String_Node_Str");
  }
  description=name + "String_Node_Str";
  for (  Tag tokenTag : tokenTags) {
    try {
      NamedTrainToken token=(NamedTrainToken)tokenClass.newInstance();
      tokens.add(token);
      token.configureFromXML(tokenTag);
      description+=token.getLongName() + "String_Node_Str" + Currency.format(this,token.getValue())+ "String_Node_Str";
    }
 catch (    Exception e) {
      throw new ConfigurationException("String_Node_Str" + tokenClassName,e);
    }
  }
  description=description.replaceFirst("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Override public void configureFromXML(Tag tag) throws ConfigurationException {
  super.configureFromXML(tag);
  Tag assignTag=tag.getChild("String_Node_Str");
  if (assignTag == null) {
    throw new ConfigurationException("String_Node_Str");
  }
  tokenClassName=assignTag.getAttributeAsString("String_Node_Str");
  if (tokenClassName == null) {
    throw new ConfigurationException("String_Node_Str");
  }
  tokenClass=Configure.getClassForName(NamedTrainToken.class,tokenClassName);
  String tokenTagName=tokenClassName.replaceAll("String_Node_Str","String_Node_Str");
  List<Tag> tokenTags=assignTag.getChildren(tokenTagName);
  if (tokenTags == null || tokenTags.isEmpty()) {
    throw new ConfigurationException("String_Node_Str" + tokenTagName + "String_Node_Str");
  }
  description=name + "String_Node_Str";
  for (  Tag tokenTag : tokenTags) {
    String tokenName=tokenTag.getAttributeAsString("String_Node_Str");
    if (!Util.hasValue(tokenName)) {
      throw new ConfigurationException("String_Node_Str");
    }
    NamedTrainToken token=Configure.create(tokenClass,this,tokenName);
    tokens.add(token);
    token.configureFromXML(tokenTag);
    description+=token.getLongName() + "String_Node_Str" + Currency.format(this,token.getValue())+ "String_Node_Str";
  }
  description=description.replaceFirst("String_Node_Str","String_Node_Str");
}
Program: 173507
Project: 173507
Buggy source:
private NameableTrain(RailsItem parent,String id){
  super(parent,id);
}

Fixed version (ground truth):
/** 
 * Created via Configure
 */
public NameableTrain(RailsItem parent,String id){
  super(parent,id);
}
Program: 173508
Project: 173508
Buggy source:
@Override public String toText(){
  NamedTrainToken token=getNameToken();
  if (token == null) {
    return getId();
  }
 else {
    return getId() + "String_Node_Str" + token.getId()+ "String_Node_Str";
  }
}

Fixed version (ground truth):
@Override public String toText(){
  NamedTrainToken token=getNameToken();
  if (token == null) {
    return super.toText();
  }
 else {
    return super.toText() + "String_Node_Str" + token.getId()+ "String_Node_Str";
  }
}
Program: 173509
Project: 173509
Buggy source:
private NamedTrainToken(RailsItem parent,String id){
  super(parent,id,NamedTrainToken.class);
}

Fixed version (ground truth):
/** 
 * Used via Configure (reflection)
 */
public NamedTrainToken(RailsItem parent,String id){
  super(parent,id,NamedTrainToken.class);
}
Program: 173513
Project: 173513
Buggy source:
public boolean buyBonusToken(BuyBonusToken action){
  String errMsg=null;
  int cost;
  SellBonusToken sbt=null;
  MoneyOwner seller=null;
  while (true) {
    sbt=action.getSpecialProperty();
    cost=sbt.getPrice();
    Owner from=sbt.getSeller();
    if (from instanceof BankPortfolio) {
      seller=bank;
    }
 else {
      seller=(MoneyOwner)from;
    }
    if (cost > operatingCompany.value().getCash()) {
      errMsg=LocalText.getText("String_Node_Str",operatingCompany.value().getId(),Currency.format(this,operatingCompany.value().getCash()),Currency.format(this,cost));
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),seller.getId(),bank.getCurrency().format(cost),errMsg));
    return false;
  }
  ChangeStack.start(this,action);
  String costText=Currency.wire(operatingCompany.value(),cost,seller);
  operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),sbt.getId(),sbt.getValue(),sbt.getLocations()));
  ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),bank.getCurrency().format(sbt.getValue()),seller.getId(),bank.getCurrency().format(sbt.getPrice())));
  sbt.setExercised();
  return true;
}

Fixed version (ground truth):
public boolean buyBonusToken(BuyBonusToken action){
  String errMsg=null;
  int cost;
  SellBonusToken sbt=null;
  MoneyOwner seller=null;
  while (true) {
    sbt=action.getSpecialProperty();
    cost=sbt.getPrice();
    Owner from=sbt.getSeller();
    if (from instanceof BankPortfolio) {
      seller=bank;
    }
 else {
      seller=(MoneyOwner)from;
    }
    if (cost > operatingCompany.value().getCash()) {
      errMsg=LocalText.getText("String_Node_Str",operatingCompany.value().getId(),Currency.format(this,operatingCompany.value().getCash()),Currency.format(this,cost));
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),seller.getId(),bank.getCurrency().format(cost),errMsg));
    return false;
  }
  ChangeStack.start(this,action);
  String costText=Currency.wire(operatingCompany.value(),cost,seller);
  operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),sbt.getId(),sbt.getValue(),sbt.getLocations()));
  ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getName(),bank.getCurrency().format(sbt.getValue()),seller.getId(),bank.getCurrency().format(sbt.getPrice())));
  sbt.setExercised();
  return true;
}
Program: 173514
Project: 173514
Buggy source:
/** 
 * Do we have any special properties?
 * @return Boolean
 */
public boolean hasSpecialProperties(){
  return specialProperties != null && !specialProperties.isEmpty();
}

Fixed version (ground truth):
/** 
 * Do we have any special properties?
 * @return Boolean
 */
public boolean hasSpecialProperties(){
  return !specialProperties.isEmpty();
}
Program: 173516
Project: 173516
Buggy source:
public ImmutableSet<SpecialProperty> getSpecialProperties(){
  return portfolio.getSpecialProperties().items();
}

Fixed version (ground truth):
public ImmutableSet<SpecialProperty> getSpecialProperties(){
  return portfolio.getPersistentSpecialProperties();
}
Program: 173517
Project: 173517
Buggy source:
@Override public boolean equalsAsOption(PossibleAction action){
  if (!(action instanceof ExchangeTokens))   return false;
  ExchangeTokens a=(ExchangeTokens)action;
  return a.tokensToExchange == tokensToExchange && a.company == company;
}

Fixed version (ground truth):
@Override public boolean equalsAsOption(PossibleAction action){
  if (!(action instanceof ExchangeTokens))   return false;
  ExchangeTokens a=(ExchangeTokens)action;
  if (a.company != this.company)   return false;
  for (int i=0; i < tokensToExchange.size(); i++) {
    if (!(a.tokensToExchange.get(i).equalsAsOption(tokensToExchange.get(i)))) {
      return false;
    }
  }
  return true;
}
Program: 173518
Project: 173518
Buggy source:
public boolean isPlaced(){
  return getParent().getBaseTokensModel().tokenIsLaid(this);
}

Fixed version (ground truth):
public boolean isPlaced(){
  return !(getOwner() == getParent());
}
Program: 173519
Project: 173519
Buggy source:
public boolean buyBonusToken(BuyBonusToken action){
  String errMsg=null;
  int cost;
  SellBonusToken sbt=null;
  MoneyOwner seller=null;
  while (true) {
    sbt=action.getSpecialProperty();
    cost=sbt.getPrice();
    seller=(MoneyOwner)sbt.getSeller();
    if (cost > operatingCompany.value().getCash()) {
      errMsg=LocalText.getText("String_Node_Str",operatingCompany.value().getId(),Currency.format(this,operatingCompany.value().getCash()),Currency.format(this,cost));
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),seller.getId(),bank.getCurrency().format(cost),errMsg));
    return false;
  }
  ChangeStack.start(this,action);
  String costText=Currency.wire(operatingCompany.value(),cost,seller);
  operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),sbt.getId(),sbt.getValue(),sbt.getLocations()));
  ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),bank.getCurrency().format(sbt.getValue()),seller.getId(),bank.getCurrency().format(sbt.getPrice())));
  sbt.setExercised();
  return true;
}

Fixed version (ground truth):
public boolean buyBonusToken(BuyBonusToken action){
  String errMsg=null;
  int cost;
  SellBonusToken sbt=null;
  MoneyOwner seller=null;
  while (true) {
    sbt=action.getSpecialProperty();
    cost=sbt.getPrice();
    Owner from=sbt.getSeller();
    if (from instanceof BankPortfolio) {
      seller=bank;
    }
 else {
      seller=(MoneyOwner)from;
    }
    if (cost > operatingCompany.value().getCash()) {
      errMsg=LocalText.getText("String_Node_Str",operatingCompany.value().getId(),Currency.format(this,operatingCompany.value().getCash()),Currency.format(this,cost));
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),seller.getId(),bank.getCurrency().format(cost),errMsg));
    return false;
  }
  ChangeStack.start(this,action);
  String costText=Currency.wire(operatingCompany.value(),cost,seller);
  operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),sbt.getId(),sbt.getValue(),sbt.getLocations()));
  ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),bank.getCurrency().format(sbt.getValue()),seller.getId(),bank.getCurrency().format(sbt.getPrice())));
  sbt.setExercised();
  return true;
}
Program: 173520
Project: 173520
Buggy source:
/** 
 * Who receives the cash when a certificate is bought. With incremental capitalization, this can be the company treasure. This method must be called <i>before</i> transferring the certificate.
 * @param cert
 * @return
 */
protected MoneyOwner getSharePriceRecipient(PublicCompany comp,Owner from,int price){
  MoneyOwner recipient;
  if (comp.hasFloated() && from == ipo.getParent() && comp.getCapitalisation() == PublicCompany.CAPITALISE_INCREMENTAL) {
    recipient=comp;
  }
 else   if (from instanceof BankPortfolio) {
    recipient=((BankPortfolio)from).getParent();
  }
 else {
    recipient=(MoneyOwner)from;
  }
  return recipient;
}

Fixed version (ground truth):
/** 
 * Who receives the cash when a certificate is bought. With incremental capitalization, this can be the company treasure. This method must be called <i>before</i> transferring the certificate.
 * @param cert
 * @return
 */
protected MoneyOwner getSharePriceRecipient(PublicCompany comp,Owner from,int price){
  MoneyOwner recipient;
  if (comp.hasFloated() && from == ipo.getParent() && comp.getCapitalisation() == PublicCompany.CAPITALISE_INCREMENTAL) {
    recipient=comp;
  }
 else   if (from instanceof BankPortfolio) {
    recipient=bank;
  }
 else {
    recipient=(MoneyOwner)from;
  }
  return recipient;
}
Program: 173521
Project: 173521
Buggy source:
public Set<Train> getAvailableNewTrains(){
  Set<Train> availableTrains=new HashSet<Train>();
  Train train;
  for (  TrainCertificateType type : trainCertTypes) {
    if (type.isAvailable()) {
      train=ipo.getTrainOfType(type);
      if (train != null) {
        availableTrains.add(train);
      }
    }
  }
  return availableTrains;
}

Fixed version (ground truth):
public Set<Train> getAvailableNewTrains(){
  Set<Train> availableTrains=new TreeSet<Train>();
  Train train;
  for (  TrainCertificateType type : trainCertTypes) {
    if (type.isAvailable()) {
      train=ipo.getTrainOfType(type);
      if (train != null) {
        availableTrains.add(train);
      }
    }
  }
  return availableTrains;
}
Program: 173522
Project: 173522
Buggy source:
/** 
 */
public BuyBonusToken(SellBonusToken specialProperty){
  this.specialProperty=specialProperty;
  this.specialPropertyId=specialProperty.getUniqueId();
  this.privateCompany=(PrivateCompany)specialProperty.getOriginalCompany();
  this.privateCompanyName=privateCompany.getId();
  this.seller=specialProperty.getSeller();
  if (seller != null)   this.sellerName=seller.getId();
  this.name=specialProperty.getId();
  this.price=specialProperty.getPrice();
  this.value=specialProperty.getValue();
  this.locationString=specialProperty.getLocationNameString();
}

Fixed version (ground truth):
/** 
 */
public BuyBonusToken(SellBonusToken specialProperty){
  this.specialProperty=specialProperty;
  this.specialPropertyId=specialProperty.getUniqueId();
  this.privateCompany=(PrivateCompany)specialProperty.getOriginalCompany();
  this.privateCompanyName=privateCompany.getId();
  this.seller=specialProperty.getSeller();
  if (seller != null)   this.sellerName=seller.getId();
  this.name=specialProperty.getName();
  this.price=specialProperty.getPrice();
  this.value=specialProperty.getValue();
  this.locationString=specialProperty.getLocationNameString();
}
Program: 173523
Project: 173523
Buggy source:
/** 
 * Implements special rules for first time operating in 1856
 */
@Override protected boolean setNextOperatingCompany(boolean initial){
  while (true) {
    if (initial || operatingCompany.value() == null || operatingCompany == null) {
      setOperatingCompany(operatingCompanies.get(0));
      initial=false;
    }
 else {
      int index=operatingCompanies.indexOf(operatingCompany.value());
      if (++index >= operatingCompanies.size()) {
        return false;
      }
      setOperatingCompany(operatingCompanies.get(index));
    }
    if (operatingCompany.value() instanceof PublicCompany_CGR)     return true;
    if (operatingCompany.value().isClosed())     continue;
    if (!operatingCompany.value().hasOperated()) {
      int soldPercentage=getSoldPercentage(operatingCompany.value());
      Train nextAvailableTrain=Iterables.get(gameManager.getTrainManager().getAvailableNewTrains(),0);
      int trainNumber;
      try {
        trainNumber=Integer.parseInt(nextAvailableTrain.getId());
      }
 catch (      NumberFormatException e) {
        trainNumber=6;
      }
      int floatPercentage=10 * trainNumber;
      log.debug("String_Node_Str" + floatPercentage + "String_Node_Str"+ soldPercentage);
      if (soldPercentage < floatPercentage) {
        DisplayBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),String.valueOf(soldPercentage),String.valueOf(floatPercentage)));
        continue;
      }
    }
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Implements special rules for first time operating in 1856
 */
@Override protected boolean setNextOperatingCompany(boolean initial){
  while (true) {
    if (initial || operatingCompany.value() == null || operatingCompany == null) {
      setOperatingCompany(operatingCompanies.get(0));
      initial=false;
    }
 else {
      int index=operatingCompanies.indexOf(operatingCompany.value());
      if (++index >= operatingCompanies.size()) {
        return false;
      }
      setOperatingCompany(operatingCompanies.get(index));
    }
    if (operatingCompany.value() instanceof PublicCompany_CGR)     return true;
    if (operatingCompany.value().isClosed())     continue;
    if (!operatingCompany.value().hasOperated()) {
      int soldPercentage=getSoldPercentage(operatingCompany.value());
      Train nextAvailableTrain=Iterables.get(gameManager.getTrainManager().getAvailableNewTrains(),0);
      log.debug("String_Node_Str" + nextAvailableTrain.getCertType().getId());
      int trainNumber;
      try {
        trainNumber=Integer.parseInt(nextAvailableTrain.getCertType().getId());
      }
 catch (      NumberFormatException e) {
        trainNumber=6;
      }
      int floatPercentage=10 * trainNumber;
      log.debug("String_Node_Str" + floatPercentage + "String_Node_Str"+ soldPercentage);
      if (soldPercentage < floatPercentage) {
        DisplayBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),String.valueOf(soldPercentage),String.valueOf(floatPercentage)));
        continue;
      }
    }
    return true;
  }
}
Program: 173524
Project: 173524
Buggy source:
@Override public void start(StockSpace startSpace){
  super.start(startSpace);
  Train nextAvailableTrain=Iterables.get(gameManager.getTrainManager().getAvailableNewTrains(),0);
  int trainNumber;
  try {
    trainNumber=Integer.parseInt(nextAvailableTrain.getId());
  }
 catch (  NumberFormatException e) {
    trainNumber=6;
  }
  trainNumberAvailableAtStart.set(trainNumber);
  if (trainNumber == 6) {
    this.capitalisation=CAPITALISE_FULL;
  }
}

Fixed version (ground truth):
@Override public void start(StockSpace startSpace){
  super.start(startSpace);
  Train nextAvailableTrain=Iterables.get(gameManager.getTrainManager().getAvailableNewTrains(),0);
  int trainNumber;
  try {
    trainNumber=Integer.parseInt(nextAvailableTrain.getCertType().getId());
  }
 catch (  NumberFormatException e) {
    trainNumber=6;
  }
  trainNumberAvailableAtStart.set(trainNumber);
  if (trainNumber == 6) {
    this.capitalisation=CAPITALISE_FULL;
  }
}
Program: 173525
Project: 173525
Buggy source:
@Override protected MoneyOwner getSharePriceRecipient(PublicCompany company,Owner from,int price){
  MoneyOwner recipient;
  if (price != 0 && !company.getId().equalsIgnoreCase(PublicCompany_CGR.NAME) && from == ipo.getParent()) {
    PublicCompany_1856 comp=(PublicCompany_1856)company;
switch (comp.getTrainNumberAvailableAtStart()) {
case 2:
case 3:
case 4:
      if (getSoldPercentage(comp) >= 50 && !comp.hasReachedDestination()) {
        recipient=bank;
        comp.addMoneyInEscrow(price);
        ReportBuffer.addWaiting(LocalText.getText("String_Node_Str",Currency.format(this,price),Currency.format(this,comp.getMoneyInEscrow()),comp.getId()));
        break;
      }
case 5:
    recipient=comp;
  break;
case 6:
default :
recipient=bank;
}
}
 else {
recipient=(MoneyOwner)from;
}
return recipient;
}

Fixed version (ground truth):
@Override protected MoneyOwner getSharePriceRecipient(PublicCompany company,Owner from,int price){
  MoneyOwner recipient;
  if (price != 0 && !company.getId().equalsIgnoreCase(PublicCompany_CGR.NAME) && from == ipo.getParent()) {
    PublicCompany_1856 comp=(PublicCompany_1856)company;
switch (comp.getTrainNumberAvailableAtStart()) {
case 2:
case 3:
case 4:
      if (getSoldPercentage(comp) >= 50 && !comp.hasReachedDestination()) {
        recipient=bank;
        comp.addMoneyInEscrow(price);
        ReportBuffer.addWaiting(LocalText.getText("String_Node_Str",Currency.format(this,price),Currency.format(this,comp.getMoneyInEscrow()),comp.getId()));
        break;
      }
case 5:
    recipient=comp;
  break;
case 6:
default :
recipient=bank;
}
}
 else if (from instanceof BankPortfolio) {
recipient=bank;
}
 else {
recipient=(MoneyOwner)from;
}
return recipient;
}
Program: 173526
Project: 173526
Buggy source:
/** 
 * This method executes the start item buy action.
 * @param player Buying player.
 * @param item Start item being bought.
 * @param price Buy price.
 */
protected void assignItem(Player player,StartItem item,int price,int sharePrice){
  Certificate primary=item.getPrimary();
  String priceText=Currency.toBank(player,price);
  ReportBuffer.add(LocalText.getText("String_Node_Str",player.getId(),primary.getId(),priceText));
  transferCertificate(primary,player.getPortfolioModel());
  checksOnBuying(primary,sharePrice);
  if (item.hasSecondary()) {
    Certificate extra=item.getSecondary();
    ReportBuffer.add(LocalText.getText("String_Node_Str",player.getId(),extra.getName()));
    transferCertificate(extra,player.getPortfolioModel());
    checksOnBuying(extra,sharePrice);
  }
  item.setSold(player,price);
}

Fixed version (ground truth):
/** 
 * This method executes the start item buy action.
 * @param player Buying player.
 * @param item Start item being bought.
 * @param price Buy price.
 */
protected void assignItem(Player player,StartItem item,int price,int sharePrice){
  Certificate primary=item.getPrimary();
  String priceText=Currency.toBank(player,price);
  ReportBuffer.add(LocalText.getText("String_Node_Str",player.getId(),primary.getName(),priceText));
  transferCertificate(primary,player.getPortfolioModel());
  checksOnBuying(primary,sharePrice);
  if (item.hasSecondary()) {
    Certificate extra=item.getSecondary();
    ReportBuffer.add(LocalText.getText("String_Node_Str",player.getId(),extra.getName()));
    transferCertificate(extra,player.getPortfolioModel());
    checksOnBuying(extra,sharePrice);
  }
  item.setSold(player,price);
}
Program: 173528
Project: 173528
Buggy source:
/** 
 * Used by Configure (via reflection) only
 */
public RevenueManager(Item parent,String id){
  super(parent,id);
}

Fixed version (ground truth):
/** 
 * Used by Configure (via reflection) only
 */
public RevenueManager(RailsRoot parent,String id){
  super(parent,id);
}
Program: 173531
Project: 173531
Buggy source:
/** 
 * Used by Configure (via reflection) only
 */
public MapManager(Item parent,String id){
  super(parent,id);
}

Fixed version (ground truth):
/** 
 * Used by Configure (via reflection) only
 */
public MapManager(RailsRoot parent,String id){
  super(parent,id);
}
Program: 173534
Project: 173534
Buggy source:
public boolean layBonusToken(LayBonusToken action){
  String errMsg=null;
  int cost=0;
  SpecialTokenLay stl=null;
  boolean extra=false;
  MapHex hex=action.getChosenHex();
  BonusToken token=action.getToken();
  while (true) {
    MapHex location=action.getChosenHex();
    if (location != hex) {
      errMsg=LocalText.getText("String_Node_Str",hex.getId(),location.getId());
      break;
    }
    stl=action.getSpecialProperty();
    if (stl != null)     extra=stl.isExtra();
    cost=0;
    if (stl != null && stl.isFree())     cost=0;
    if (cost > operatingCompany.value().getCash()) {
      errMsg=LocalText.getText("String_Node_Str",operatingCompany.value().getId());
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",token.getId(),hex.getId(),Bank.format(cost),errMsg));
    return false;
  }
  if (hex.layBonusToken(token,gameManager.getPhaseManager())) {
    operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),token.getId(),token.getValue(),Collections.singletonList(hex)));
    token.setUser(operatingCompany.value());
    ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),token.getId(),Bank.format(token.getValue()),hex.getId()));
    if (stl != null) {
      stl.setExercised();
      currentSpecialTokenLays.remove(action);
      log.debug("String_Node_Str" + (extra ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str");
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean layBonusToken(LayBonusToken action){
  String errMsg=null;
  int cost=0;
  SpecialTokenLay stl=null;
  boolean extra=false;
  MapHex hex=action.getChosenHex();
  BonusToken token=action.getToken();
  while (true) {
    MapHex location=action.getChosenHex();
    if (location != hex) {
      errMsg=LocalText.getText("String_Node_Str",hex.getId(),location.getId());
      break;
    }
    stl=action.getSpecialProperty();
    if (stl != null)     extra=stl.isExtra();
    cost=0;
    if (stl != null && stl.isFree())     cost=0;
    if (cost > operatingCompany.value().getCash()) {
      errMsg=LocalText.getText("String_Node_Str",operatingCompany.value().getId());
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",token.getId(),hex.getId(),Bank.format(cost),errMsg));
    return false;
  }
  getRoot().getChangeStack().newChangeSet(action);
  if (hex.layBonusToken(token,gameManager.getPhaseManager())) {
    operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),token.getId(),token.getValue(),Collections.singletonList(hex)));
    token.setUser(operatingCompany.value());
    ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),token.getId(),Bank.format(token.getValue()),hex.getId()));
    if (stl != null) {
      stl.setExercised();
      currentSpecialTokenLays.remove(action);
      log.debug("String_Node_Str" + (extra ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str");
    }
  }
  return true;
}
Program: 173536
Project: 173536
Buggy source:
/** 
 * The current Company is done operating.
 * @param company Name of the company that finished operating.
 * @return False if an error is found.
 */
public boolean done(){
  if (operatingCompany.value().getPortfolioModel().getNumberOfTrains() == 0 && operatingCompany.value().mustOwnATrain()) {
  }
  nextStep();
  if (getStep() == GameDef.OrStep.FINAL) {
    finishTurn();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * The current Company is done operating.
 * @param action TODO
 * @param company Name of the company that finished operating.
 * @return False if an error is found.
 */
public boolean done(NullAction action){
  if (operatingCompany.value().getPortfolioModel().getNumberOfTrains() == 0 && operatingCompany.value().mustOwnATrain()) {
  }
  getRoot().getChangeStack().newChangeSet(action);
  nextStep();
  if (getStep() == GameDef.OrStep.FINAL) {
    finishTurn();
  }
  return true;
}
Program: 173537
Project: 173537
Buggy source:
protected boolean buyRight(UseSpecialProperty action){
  String errMsg=null;
  SpecialProperty sp=action.getSpecialProperty();
  if (!(sp instanceof SpecialRight)) {
    errMsg="String_Node_Str" + sp.toString();
  }
  SpecialRight right=(SpecialRight)sp;
  String rightName=right.getId();
  String rightValue=right.getValue();
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",action.getCompanyName(),rightName,Bank.format(right.getCost()),errMsg));
    return false;
  }
  operatingCompany.value().setRight(rightName,rightValue);
  MoneyModel.cashMove(operatingCompany.value(),bank,right.getCost());
  ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),rightName,Bank.format(right.getCost())));
  sp.setExercised();
  return true;
}

Fixed version (ground truth):
protected boolean buyRight(UseSpecialProperty action){
  String errMsg=null;
  SpecialProperty sp=action.getSpecialProperty();
  if (!(sp instanceof SpecialRight)) {
    errMsg="String_Node_Str" + sp.toString();
  }
  SpecialRight right=(SpecialRight)sp;
  String rightName=right.getId();
  String rightValue=right.getValue();
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",action.getCompanyName(),rightName,Bank.format(right.getCost()),errMsg));
    return false;
  }
  getRoot().getChangeStack().newChangeSet(action);
  operatingCompany.value().setRight(rightName,rightValue);
  MoneyModel.cashMove(operatingCompany.value(),bank,right.getCost());
  ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),rightName,Bank.format(right.getCost())));
  sp.setExercised();
  return true;
}
Program: 173538
Project: 173538
Buggy source:
public boolean setRevenueAndDividend(SetDividend action){
  String errMsg=validateSetRevenueAndDividend(action);
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",Bank.format(action.getActualRevenue()),action.getCompanyName(),errMsg));
    return false;
  }
  ReportBuffer.add(LocalText.getText("String_Node_Str",action.getCompanyName(),Bank.format(action.getActualRevenue())));
  int remainingAmount=checkForDeductions(action);
  if (remainingAmount < 0) {
    return true;
  }
  executeSetRevenueAndDividend(action);
  return true;
}

Fixed version (ground truth):
public boolean setRevenueAndDividend(SetDividend action){
  String errMsg=validateSetRevenueAndDividend(action);
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",Bank.format(action.getActualRevenue()),action.getCompanyName(),errMsg));
    return false;
  }
  getRoot().getChangeStack().newChangeSet(action);
  ReportBuffer.add(LocalText.getText("String_Node_Str",action.getCompanyName(),Bank.format(action.getActualRevenue())));
  int remainingAmount=checkForDeductions(action);
  if (remainingAmount < 0) {
    return true;
  }
  executeSetRevenueAndDividend(action);
  return true;
}
Program: 173540
Project: 173540
Buggy source:
protected boolean repayLoans(RepayLoans action){
  String errMsg=validateRepayLoans(action);
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",action.getCompanyName(),action.getNumberRepaid(),Bank.format(action.getPrice()),errMsg));
    return false;
  }
  int repayment=action.getNumberRepaid() * operatingCompany.value().getValuePerLoan();
  if (repayment > 0 && repayment > operatingCompany.value().getCash()) {
    int remainder=repayment - operatingCompany.value().getCash();
    Player president=operatingCompany.value().getPresident();
    int presCash=president.getCashValue();
    if (remainder > presCash) {
      int cashToBeRaisedByPresident=remainder - presCash;
      log.info("String_Node_Str" + remainder + "String_Node_Str");
      log.info("String_Node_Str" + presCash + "String_Node_Str"+ cashToBeRaisedByPresident+ "String_Node_Str");
      savedAction=action;
      gameManager.startShareSellingRound(operatingCompany.value().getPresident(),cashToBeRaisedByPresident,operatingCompany.value(),false);
      return true;
    }
  }
  if (repayment > 0)   executeRepayLoans(action);
  return true;
}

Fixed version (ground truth):
protected boolean repayLoans(RepayLoans action){
  String errMsg=validateRepayLoans(action);
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",action.getCompanyName(),action.getNumberRepaid(),Bank.format(action.getPrice()),errMsg));
    return false;
  }
  int repayment=action.getNumberRepaid() * operatingCompany.value().getValuePerLoan();
  if (repayment > 0 && repayment > operatingCompany.value().getCash()) {
    int remainder=repayment - operatingCompany.value().getCash();
    Player president=operatingCompany.value().getPresident();
    int presCash=president.getCashValue();
    if (remainder > presCash) {
      int cashToBeRaisedByPresident=remainder - presCash;
      log.info("String_Node_Str" + remainder + "String_Node_Str");
      log.info("String_Node_Str" + presCash + "String_Node_Str"+ cashToBeRaisedByPresident+ "String_Node_Str");
      savedAction=action;
      getRoot().getChangeStack().newChangeSet(action);
      gameManager.startShareSellingRound(operatingCompany.value().getPresident(),cashToBeRaisedByPresident,operatingCompany.value(),false);
      return true;
    }
  }
  getRoot().getChangeStack().newChangeSet(action);
  if (repayment > 0)   executeRepayLoans(action);
  return true;
}
Program: 173542
Project: 173542
Buggy source:
public boolean buyBonusToken(BuyBonusToken action){
  String errMsg=null;
  int cost;
  SellBonusToken sbt=null;
  CashOwner seller=null;
  while (true) {
    sbt=action.getSpecialProperty();
    cost=sbt.getPrice();
    seller=(CashOwner)sbt.getSeller();
    if (cost > operatingCompany.value().getCash()) {
      errMsg=LocalText.getText("String_Node_Str",operatingCompany.value().getId(),Bank.format(operatingCompany.value().getCash()),Bank.format(cost));
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),seller.getId(),Bank.format(cost),errMsg));
    return false;
  }
  MoneyModel.cashMove(operatingCompany.value(),seller,cost);
  operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),sbt.getId(),sbt.getValue(),sbt.getLocations()));
  ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),Bank.format(sbt.getValue()),seller.getId(),Bank.format(sbt.getPrice())));
  sbt.setExercised();
  return true;
}

Fixed version (ground truth):
public boolean buyBonusToken(BuyBonusToken action){
  String errMsg=null;
  int cost;
  SellBonusToken sbt=null;
  CashOwner seller=null;
  while (true) {
    sbt=action.getSpecialProperty();
    cost=sbt.getPrice();
    seller=(CashOwner)sbt.getSeller();
    if (cost > operatingCompany.value().getCash()) {
      errMsg=LocalText.getText("String_Node_Str",operatingCompany.value().getId(),Bank.format(operatingCompany.value().getCash()),Bank.format(cost));
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),seller.getId(),Bank.format(cost),errMsg));
    return false;
  }
  getRoot().getChangeStack().newChangeSet(action);
  MoneyModel.cashMove(operatingCompany.value(),seller,cost);
  operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),sbt.getId(),sbt.getValue(),sbt.getLocations()));
  ReportBuffer.add(LocalText.getText("String_Node_Str",operatingCompany.value().getId(),sbt.getId(),Bank.format(sbt.getValue()),seller.getId(),Bank.format(sbt.getPrice())));
  sbt.setExercised();
  return true;
}
Program: 173543
Project: 173543
Buggy source:
protected boolean executeClosePrivate(ClosePrivate action){
  PrivateCompany priv=action.getPrivateCompany();
  log.debug("String_Node_Str" + priv.getId());
  String errMsg=null;
  if (priv.isClosed())   errMsg=LocalText.getText("String_Node_Str",priv.getId());
  if (errMsg != null) {
    DisplayBuffer.add(errMsg);
    return false;
  }
  priv.setClosed();
  return true;
}

Fixed version (ground truth):
protected boolean executeClosePrivate(ClosePrivate action){
  PrivateCompany priv=action.getPrivateCompany();
  log.debug("String_Node_Str" + priv.getId());
  String errMsg=null;
  if (priv.isClosed())   errMsg=LocalText.getText("String_Node_Str",priv.getId());
  if (errMsg != null) {
    DisplayBuffer.add(errMsg);
    return false;
  }
  getRoot().getChangeStack().newChangeSet(action);
  priv.setClosed();
  return true;
}
Program: 173545
Project: 173545
Buggy source:
public boolean discardTrain(DiscardTrain action){
  Train train=action.getDiscardedTrain();
  PublicCompany company=action.getCompany();
  String companyName=company.getId();
  String errMsg=null;
  while (true) {
    if (getStep() != GameDef.OrStep.BUY_TRAIN && getStep() != GameDef.OrStep.DISCARD_TRAINS) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (train == null && action.isForced()) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (!company.getPortfolioModel().getTrainList().contains(train)) {
      errMsg=LocalText.getText("String_Node_Str",company.getId(),train.getId());
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",companyName,(train != null ? train.getId() : "String_Node_Str"),errMsg));
    return false;
  }
  if (train.getCertType().getPotentialTrainTypes().size() > 1) {
    train.setType(null);
  }
  (train.isObsolete() ? scrapHeap : pool).addTrain(train);
  ReportBuffer.add(LocalText.getText("String_Node_Str",companyName,train.getId()));
  if (!checkForExcessTrains()) {
    setCurrentPlayer(operatingCompany.value().getPresident());
    stepObject.set(GameDef.OrStep.BUY_TRAIN);
  }
  return true;
}

Fixed version (ground truth):
public boolean discardTrain(DiscardTrain action){
  Train train=action.getDiscardedTrain();
  PublicCompany company=action.getCompany();
  String companyName=company.getId();
  String errMsg=null;
  while (true) {
    if (getStep() != GameDef.OrStep.BUY_TRAIN && getStep() != GameDef.OrStep.DISCARD_TRAINS) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (train == null && action.isForced()) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (!company.getPortfolioModel().getTrainList().contains(train)) {
      errMsg=LocalText.getText("String_Node_Str",company.getId(),train.getId());
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",companyName,(train != null ? train.getId() : "String_Node_Str"),errMsg));
    return false;
  }
  getRoot().getChangeStack().newChangeSet(action);
  if (train.getCertType().getPotentialTrainTypes().size() > 1) {
    train.setType(null);
  }
  (train.isObsolete() ? scrapHeap : pool).addTrain(train);
  ReportBuffer.add(LocalText.getText("String_Node_Str",companyName,train.getId()));
  if (!checkForExcessTrains()) {
    setCurrentPlayer(operatingCompany.value().getPresident());
    stepObject.set(GameDef.OrStep.BUY_TRAIN);
  }
  return true;
}
Program: 173546
Project: 173546
Buggy source:
protected boolean takeLoans(TakeLoans action){
  String errMsg=validateTakeLoans(action);
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",action.getCompanyName(),action.getNumberTaken(),Bank.format(action.getPrice()),errMsg));
    return false;
  }
  executeTakeLoans(action);
  return true;
}

Fixed version (ground truth):
protected boolean takeLoans(TakeLoans action){
  String errMsg=validateTakeLoans(action);
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",action.getCompanyName(),action.getNumberTaken(),Bank.format(action.getPrice()),errMsg));
    return false;
  }
  getRoot().getChangeStack().newChangeSet(action);
  executeTakeLoans(action);
  return true;
}
Program: 173547
Project: 173547
Buggy source:
public void setClosed(){
  closed.set(true);
  PortfolioOwner shareDestination;
  if (canBeRestarted) {
    if (certsAreInitiallyAvailable) {
      shareDestination=bank.getIpo();
    }
 else {
      shareDestination=bank.getUnavailable();
    }
    reinitialise();
  }
 else {
    shareDestination=bank.getScrapHeap();
    inGameState.set(false);
  }
  for (  PublicCertificate cert : certificates.view()) {
    if (cert.getOwner() != shareDestination.getParent()) {
      shareDestination.getPortfolioModel().getCertificatesModel().getPortfolio().moveInto(cert);
    }
  }
  portfolio.getTrainsModel().getPortfolio().moveAll(bank.getPool());
  int cash=treasury.value();
  if (cash > 0) {
    treasury.setSuppressZero(true);
    MoneyModel.cashMoveToBank(this,cash);
  }
  lastRevenue.setSuppressZero(true);
  setLastRevenue(0);
  for (  BaseToken token : baseTokens.getLaidTokens()) {
    baseTokens.addFreeToken(token);
  }
  stockMarket.close(this);
}

Fixed version (ground truth):
public void setClosed(){
  closed.set(true);
  PortfolioOwner shareDestination;
  if (canBeRestarted) {
    if (certsAreInitiallyAvailable) {
      shareDestination=bank.getIpo();
    }
 else {
      shareDestination=bank.getUnavailable();
    }
    reinitialise();
  }
 else {
    shareDestination=bank.getScrapHeap();
    inGameState.set(false);
  }
  for (  PublicCertificate cert : certificates) {
    if (cert.getOwner() != shareDestination) {
      cert.moveTo(shareDestination);
    }
  }
  portfolio.getTrainsModel().getPortfolio().moveAll(bank.getPool());
  int cash=treasury.value();
  if (cash > 0) {
    treasury.setSuppressZero(true);
    MoneyModel.cashMoveToBank(this,cash);
  }
  lastRevenue.setSuppressZero(true);
  setLastRevenue(0);
  for (  BaseToken token : baseTokens.getLaidTokens()) {
    baseTokens.addFreeToken(token);
  }
  stockMarket.close(this);
}
Program: 173548
Project: 173548
Buggy source:
/** 
 * Swap this Portfolio's President certificate for common shares in another Portfolio.
 * @param company The company whose Presidency is handed over.
 * @param other The new President's portfolio.
 * @return The common certificates returned.
 */
public List<PublicCertificate> swapPresidentCertificate(PublicCompany company,PortfolioModel other){
  return null;
}

Fixed version (ground truth):
/** 
 * Swap this Portfolio's President certificate for common shares in another Portfolio.
 * @param company The company whose Presidency is handed over.
 * @param other The new President's portfolio.
 * @return The common certificates returned.TODO: Rewrite the method replacing PortfolioModel with Owner
 */
public List<PublicCertificate> swapPresidentCertificate(PublicCompany company,PortfolioModel other){
  List<PublicCertificate> swapped=new ArrayList<PublicCertificate>();
  PublicCertificate swapCert;
  PublicCertificate cert=this.findCertificate(company,true);
  if (cert == null)   return null;
  int shares=cert.getShares();
  if (other.ownsCertificates(company,1,false) >= shares) {
    for (int i=0; i < shares; i++) {
      swapCert=other.findCertificate(company,1,false);
      swapCert.moveTo(getParent());
      swapped.add(swapCert);
    }
  }
 else   if (other.ownsCertificates(company,shares,false) >= 1) {
    swapCert=other.findCertificate(company,2,false);
    swapCert.moveTo(getParent());
    swapped.add(swapCert);
  }
 else {
    return null;
  }
  cert.moveTo(other.getParent());
  return swapped;
}