Пример #1
0
 @Override
 protected Object getColumnValue(SoldItem item, int columnIndex) {
   switch (columnIndex) {
     case 0:
       return item.getId();
     case 1:
       return item.getName();
     case 2:
       return item.getPrice();
     case 3:
       return item.getQuantity();
     case 4:
       return item.getSum();
   }
   throw new IllegalArgumentException("Column index out of range");
 }
Пример #2
0
  @Override
  public String toString() {
    final StringBuffer buffer = new StringBuffer();

    for (int i = 0; i < headers.length; i++) buffer.append(headers[i] + "\t");
    buffer.append("\n");

    for (final SoldItem item : getRows()) {
      buffer.append(item.getId() + "\t");
      buffer.append(item.getName() + "\t");
      buffer.append(item.getPrice() + "\t");
      buffer.append(item.getQuantity() + "\t");
      buffer.append(item.getSum() + "\t");
      buffer.append("\n");
    }

    return buffer.toString();
  }