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

** JAVA ** You now decide to include a counter to keep track of how many Custome

ID: 3749623 • Letter: #

Question

** JAVA **

You now decide to include a counter to keep track of how many Customer objects have been created.

Write:

the declaration of a variable to keep track of this information

the code that would be placed inside the Customer constructor

a getter method for this variable

Note: You are not counting how many orders a customer has. You are counting how many customers there are.

import java.util.ArrayList; class Order private String orderID; private double total; // cost of the order public Order(String orderID, double total) this.orderID = orderID; this.total-total; public String getOrderIDO return orderID; public double getTotalO return total; class Customer private String name; private ArrayList«order» orderList; // variable to keep tcasks.of objects creates for Customer private static int objCount; public String getName()

Explanation / Answer

The only way in this code to keep track of number of customer objects created is to add a static variable which will be kept in the class Customer and increment this variable by one inside the constructor of Customer class so that every time an object of customer class is created, then this variable gets incremented by one and you can add a getter method to get the count of the same.

Please comment if you face any difficulty or if you have any doubt.