001package edu.pdx.cs410J.di; 002 003/** 004 * A subclass of {@link BookInventoryTableModel} that adds an extra column. 005 */ 006class CheckoutInventoryTableModel extends BookInventoryTableModel 007{ 008 public CheckoutInventoryTableModel( BookInventory inventory ) 009 { 010 super( inventory ); 011 } 012 013 @Override 014 public int getColumnCount() 015 { 016 return super.getColumnCount() + 1; 017 } 018 019 @Override 020 public String getColumnName( int column ) 021 { 022 if ( isLastColumn( column ) ) 023 { 024 return ""; 025 } 026 else 027 { 028 return super.getColumnName( column ); 029 } 030 } 031 032 @Override 033 public Object getValueAt( int row, int column ) 034 { 035 if ( isLastColumn( column ) ) 036 { 037 return getBook( row ); 038 } 039 else 040 { 041 return super.getValueAt( row, column ); 042 } 043 } 044 045 public boolean isLastColumn( int column ) 046 { 047 return column == this.getColumnCount() -1; 048 } 049 050 @Override 051 public boolean isCellEditable( int row, int column ) 052 { 053 return isLastColumn( column ) || super.isCellEditable( row, column ); 054 } 055}