Package gui

Source Code of gui.DuellTableModel

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gui;

import data.Duell;
import java.util.LinkedList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
*
* @author nadine
*/
public class DuellTableModel extends AbstractTableModel
{
  private static DuellTableModel theInstance = null;

  public static DuellTableModel getInstance()
  {
    if (theInstance == null)
    {
      theInstance = new DuellTableModel();
    }
    return theInstance;
  }
  private List<Duell> duelle = new LinkedList<Duell>();
  private final static String[] colName = {"Runde", "Punkte", "Spieler1", "Spieler2", "Punkte"};

  private DuellTableModel()
  {
  }

  public int getRowCount()
  {
    return duelle.size();
  }

  public int getColumnCount()
  {
    return colName.length;
  }

  public Object getValueAt(int rowIndex, int columnIndex)
  {
    final Duell duell = duelle.get(rowIndex);
    switch (columnIndex)
    {
      case 0:
        return duell.getRn();
      case 1:
        return duell.getP1();
      case 2:
        return duell.getW1() ? "kooperieren" : "nicht kooperieren";
      case 3:
        return duell.getW2() ? "kooperieren" : "nicht kooperieren";
      case 4:
        return duell.getP2();
      default:
        return "?";
    }
  }

  public String getColumnName(int column)
  {
    return colName[column];
  }
}
TOP

Related Classes of gui.DuellTableModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.