-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerManagement.java
More file actions
38 lines (31 loc) · 1016 Bytes
/
Copy pathCustomerManagement.java
File metadata and controls
38 lines (31 loc) · 1016 Bytes
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
import java.util.*;
public class CustomerManagement {
private LinkedList<Customer> customers;
private TreeMap<Integer, Customer> customerMap;
public CustomerManagement() {
customers = new LinkedList<>();
customerMap = new TreeMap<>();
}
public void registerCustomer(Customer customer) {
customers.add(customer);
customerMap.put(customer.id, customer);
System.out.println("Customer registered successfully!");
}
public void updateCustomerInformation(Customer customer) {
customerMap.put(customer.id, customer);
System.out.println("Customer information is updated.");
}
public Customer searchCustomerById(int id) {
return customerMap.get(id);
}
}
class Customer {
int id;
String name;
String phoneNumber;
Customer(int id, String name, String phoneNumber) {
this.id = id;
this.name = name;
this.phoneNumber = phoneNumber;
}
}