-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInvoiceList.java
More file actions
64 lines (48 loc) · 1.38 KB
/
InvoiceList.java
File metadata and controls
64 lines (48 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.company;
import java.util.*;
public class InvoiceList {
private List<Invoice> invoices = new LinkedList<Invoice>();
public Iterator<Invoice> getInvoices() {
return invoices.iterator();
}
public int NumInvoices()
{
return invoices.size();
}
public int NumOutstandingInvoices()
{
int total = 0;
for (int i = 0; i < invoices.size(); i++)
{
Invoice temp = invoices.get(i);
if (temp.paid == false)
{
total++;
}
}
return total;
}
public void AddInvoice(cart userCart, int total)
{
Invoice newInvoice = new Invoice(userCart,total);
invoices.add(newInvoice);
userCart.emptyCart();
}
public int IDcheck (int ID) {
for (int i=0; i < invoices.size(); i++) {
Invoice temp = invoices.get(i);
if (ID == temp.getId()) {
System.out.println("ID found");
return i;
}
}
System.out.println("ERROR: ID is not in database");
return -1;
}
public Invoice get_listed_obj (int position) {
return invoices.get(position);
}
public void set_listed_obj (int position, Invoice update) {
invoices.set(position, update);
}
}