Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zda;
- import java.util.ArrayList;
- public class InvoiceManager
- {
- private int maxNumber = 10;
- private ArrayList<Invoice> listOfInvoices = new ArrayList<Invoice>();
- public void addInvoice(Invoice w) throws IllegalArgumentException{
- if(listOfInvoices.size()< maxNumber)
- listOfInvoices.add(w);
- else
- throw new IllegalArgumentException("No space for a new invoice");
- }
- public void removeInvoice(Invoice w){
- listOfInvoices.remove(w);
- }
- public Invoice[] getList(){
- return (Invoice[]) listOfInvoices.toArray(new Invoice[listOfInvoices.size()]);
- }
- public InvoiceManager(int max){
- maxNumber = max;
- }
- }
Add Comment
Please, Sign In to add comment