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

You will write a class called Customer. A customer is described by: e a name an

ID: 3747285 • Letter: Y

Question

You will write a class called Customer. A customer is described by: e a name an ArrayList of Order objects Use good principles of class design. Here is the Order class: . public class Order { private String orderID; private double total; I/ cost of the order public Order (String orderID, double total) ( this.orderID orderID; this.total total; public String getOrderIDO) return orderID; public double getTotal() return total; Here is the class header, instance data variables, and one constructor public class Customer private String name; private ArrayList«order» orderList; public Customer (String name) [ this.name name orderList new ArrayList();

Explanation / Answer

import java.util.*; class Order{ private String orderID; private double total; public Order(String orderID, double total){ this.orderID = orderID; this.total = total; } public String getOrderID(){ return orderID; } public double getTotal(){ return total; } } class Customer{ private String name; private ArrayList orderList; public Customer(String name){ this.name = name; orderList = new ArrayList(); } public Customer(String name, ArrayList list){ this.name = name; orderList = list; } public String getName() { return name; } public void setName(String name) { this.name = name; } public ArrayList getOrderList() { return orderList; } public void setOrderList(ArrayList orderList) { this.orderList = orderList; } @Override public String toString(){ return name+" "+orderList.size(); } public double getMoneyOwned(){ double ans = 0; for(Order o : orderList){ ans += o.getTotal(); } return ans; } public void addOrder(Order ord){ if(getMoneyOwned()
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