String line;
for (int i = 0; i < products.size(); i++) {
Supplier product = products.get(i);
line = product.getProductName() + "\t";
line += product.getItemNumber() + "\t";
line += product.getPrice() + "\t";
line += product.getUnitsInStock() + "\t";
line += product.getSupplierName() + "\n";
try {
writer.write(line);
} catch (IOException e) {
JOptionPane.showMessageDialog(null,
"Could not write in the inventory file.");
}
}
--- Update ---
this is the Supplier class
public class Supplier extends Inventary {
/**
* Supplier Name
*/
private String supplierName;
/**
* Default constructor;
*/
public Supplier() {
}
/**
* Constructor should have 5 parameters:
*
* - Item Number
*
* - Product Name
*
* - Number of Units in Stock
*
* - Price of each Unit
*
* - Supplier Name
*/
public Supplier(int itemNumber, String productName, int unitsInStock,
double price, String supplierName) {
/*
* Note you will use the super keyword to invoke the constructor in your
* Product class.
*/
// super(itemNumber, productName, unitsInStock, price);
this.itemNumber = itemNumber;
this.productName = productName;
this.unitsInStock = unitsInStock;
this.price = price;
this.supplierName = supplierName;
}
/**
* return the product name
*/
public String getProductName(){
return productName;
}
/**
* return the unitsInStock
*/
public int getUnitsInStock(){
return unitsInStock;
}
/**
* return the price.
*/
public double getprice(){
return price;
}
/**
* @return the supplierName
*/
public String getSupplierName() {
return supplierName;
}
/**
* need to set the itemNumber.
*/
public void setItemNumber( int itemNumber ) {
this.itemNumber = itemNumber;
}
/**
* product name to set
*/
public void setName ( String productName ) {
this.productName = productName;
}
/**
* price to set
*/
public void setPrice ( double price ) {
this.price = price;
}
/**
* @param supplierName
* the supplierName to set
*/
public void setSupplierName(String supplierName) {
this.supplierName = supplierName;
}
/**
* This method returns the product of price and available units multiplied
* by 5% ((price * product) * .05);
*/
public double calculateRestockFee() {
return calculateInventory() * .05;
}
/**
* This method returns the product of price and available units plus the
* restock fee.
*/
public double calculateInventory() {
return calculateInventory() + calculateRestockFee();
}
}