I am trying to create mutliple objects of type class I. Then I want to pass these values ββto a list of arrays. How to create objects using a while loop that have different names. For example, here is my code now, but it will only make an object with the same name.
Customer cust = new Customer("bob", 20.0);
and my constructor, if you want to see:
public Customer(String customerName, double amount) { String name=customerName; double sale=amount; }
StoreTest class (with main method):
import java.util.ArrayList; import java.util.Scanner; public class StoreTest { ArrayList<Customer> store = new ArrayList<Customer>(); public static void main (String[] args) { double sale=1.0;
Customer Class:
public class Customer { private String name; private double sale; public Customer() { } public Customer(String customerName, double amount) { name=customerName; sale=amount; } }
Save class (there are methods for interacting with arraylist:
import java.util.ArrayList; public class Store {
source share