Guest User

public class InvoiceManager

a guest
Apr 19th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. package zda;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. public class InvoiceManager
  6. {
  7.  
  8.     private int maxNumber = 10;
  9.     private ArrayList<Invoice> listOfInvoices = new ArrayList<Invoice>();
  10.    
  11.     public void addInvoice(Invoice w) throws IllegalArgumentException{
  12.         if(listOfInvoices.size()< maxNumber)
  13.             listOfInvoices.add(w);
  14.         else
  15.             throw new IllegalArgumentException("No space for a new invoice");
  16.     }
  17.     public void removeInvoice(Invoice w){
  18.         listOfInvoices.remove(w);
  19.     }
  20.     public Invoice[] getList(){
  21.         return (Invoice[]) listOfInvoices.toArray(new Invoice[listOfInvoices.size()]);
  22.     }
  23.    
  24.     public InvoiceManager(int max){
  25.         maxNumber = max;
  26.     }
  27.    
  28. }
Add Comment
Please, Sign In to add comment