Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In java, write a customer class that minimally stores the following data fields

ID: 3825415 • Letter: I

Question

In java, write a customer class that minimally stores the following data fields for a customer:

–Name

–Customer phone number

–Total amount of purchase

–Time duration of membership by month

The following methods should also be provided:

–A constructor that initializes the name and phone number

–A method that returns the customer name field

–A method that returns the customer phone number

–A method that determines if two customer objects are equal if their name and phone number are the same

–Methods to retrieve the total amount of purchase

–Methods to update the total amount of purchase if a new purchase has been placed by the customer

–Method to set and retrieve the time duration of membership by month

Explanation / Answer

public Customer getCustomer(@PathParam("id") String customerId) {
Customer customer = null;
try {
customer = findById(customerId);
} catch (Exception ex)
{
logger.log(Level.SEVERE,
"Error calling searchCustomer() for customerId {0}. {1}",
new Object[]{customerId, ex.getMessage()});
}
return customer;
}
private Customer findById(String customerId) throws IOException {
properties properties = new Properties();
properties.load(new FileInputStream(DATA_STORE));
String rawData = properties.getProperty(customerId);
if (rawData != null) {
final String[] field = rawData.split(",");
Address address = new Address();
Customer customer = new Customer();
customer.setId(Integer.parseInt(customerId));
customer.setAddress(address);
customer.setFirstname(field[0]);
customer.setLastname(field[1]);
address.setNumber(Integer.parseInt(field[2]));
address.setStreet(field[3]);
address.setCity(field[4]);
address.setState(field[5]);
address.setZip(field[6]);
return customer;
}
return null;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote