/*
* 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];
}
}