package [Link].
management;
import [Link].*;
// Custom Exceptions
class InvalidCustomerException extends Exception {
public InvalidCustomerException(String message) {
super(message);
}
}
class DuplicateLeadException extends Exception {
public DuplicateLeadException(String message) {
super(message);
}
}
// Customer Class
class Customer {
private int id;
private String name;
private String contact;
private List<String> history;
public Customer(int id, String name, String contact) {
[Link] = id;
[Link] = name;
[Link] = contact;
[Link] = new ArrayList<>();
}
public int getId() { return id; }
public String getName() { return name; }
public String getContact() { return contact; }
public void addHistory(String record) { [Link](record); }
public List<String> getHistory() { return history; }
}
// Inheritance Example
class CorporateCustomer extends Customer {
private String companyName;
public CorporateCustomer(int id, String name, String contact, String companyName) {
super(id, name, contact);
[Link] = companyName;
}
public String getCompanyName() { return companyName; }
}
class IndividualCustomer extends Customer {
public IndividualCustomer(int id, String name, String contact) {
super(id, name, contact);
}
}
// Lead Class
class Lead {
private int id;
private String potentialCustomer;
public Lead(int id, String potentialCustomer) {
[Link] = id;
[Link] = potentialCustomer;
}
public int getId() { return id; }
public String getPotentialCustomer() { return potentialCustomer; }
}
// Sales Representative
class SalesRepresentative {
private int id;
private String name;
private List<Customer> assignedCustomers;
public SalesRepresentative(int id, String name) {
[Link] = id;
[Link] = name;
[Link] = new ArrayList<>();
}
public void assignCustomer(Customer customer) {
[Link](customer);
}
public List<Customer> getAssignedCustomers() {
return assignedCustomers;
}
}
// Service Request (Polymorphism Example)
abstract class ServiceRequest {
protected int requestId;
protected Customer customer;
protected String issue;
public ServiceRequest(int requestId, Customer customer, String issue) {
[Link] = requestId;
[Link] = customer;
[Link] = issue;
}
public abstract void resolve();
}
class PhoneSupport extends ServiceRequest {
public PhoneSupport(int requestId, Customer customer, String issue) {
super(requestId, customer, issue);
}
@Override
public void resolve() {
[Link]("Phone support resolving issue: " + issue);
}
}
class EmailSupport extends ServiceRequest {
public EmailSupport(int requestId, Customer customer, String issue) {
super(requestId, customer, issue);
}
@Override
public void resolve() {
[Link]("Email support resolving issue: " + issue);
}
}
// Invoice Class
class Invoice {
private int invoiceId;
private Customer customer;
private double amount;
public Invoice(int invoiceId, Customer customer, double amount) {
[Link] = invoiceId;
[Link] = customer;
[Link] = amount;
}
public void generateInvoice() {
[Link]("Invoice generated for customer: " + [Link]() + ", Amount: " + amount);
}
}
// Main CRM System
public class CRMSystem {
private List<Customer> customers = new ArrayList<>();
private Map<Integer, ServiceRequest> serviceRequests = new HashMap<>();
private Queue<Lead> leads = new LinkedList<>();
public void addCustomer(Customer customer) throws InvalidCustomerException {
for (Customer c : customers) {
if ([Link]() == [Link]()) {
throw new InvalidCustomerException("Customer with ID " + [Link]() + " already exists.");
}
}
[Link](customer);
}
public void addLead(Lead lead) throws DuplicateLeadException {
for (Lead l : leads) {
if ([Link]() == [Link]()) {
throw new DuplicateLeadException("Lead with ID " + [Link]() + " already exists.");
}
}
[Link](lead);
}
public void createServiceRequest(ServiceRequest request) {
[Link]([Link], request);
}
public static void main(String[] args) {
CRMSystem crm = new CRMSystem();
try {
Customer c1 = new IndividualCustomer(1, "John Doe", "john@[Link]");
[Link](c1);
[Link](new PhoneSupport(101, c1, "Internet not working"));
[Link](101).resolve();
} catch (InvalidCustomerException e) {
[Link]("Error: " + [Link]());
}
}
}