The Customer.java class should have the following instance variables:
-
name: String. It should be at least 5 characters long.
-
itemsPurchased: int. Should be incremented with every item purchased
-
moneySpent: double. The amount of money spent in shopping, also increments with every item purchased
Be sure to implement all the set and get methods, the toString method and the equals method. In this case the equals
method should compare the customer's name only.
You will have a driver class (main class) called Store.java. This class will have the
following menu:
-
Create a new customer
This will request/validate all the customer information, so that a customer can be added to the array of customers.
Duplicate customer names are ok.
-
Customer wants to shop
This will take a particular customer to the program that you created in assignment 2.
-
Find and print a customer (find using name)
The customer name will be entered by the user. Your program will find the customer and print all
the information about the customer. If there are duplicate customers, you should print them all.
-
Print all customers that have spent more than a given amount of money. The amount of money will be given by the user.
-
Print all the store customers
-
End the program
For this class you should implement a find method.
-
public static Customer[ ] find(String name){
This method
will take a String name as a parameter and will return an array of customers. It is necessary to return an array because
more than one customer may have the same name. If no customers are found with that name, then return an empty array.
You will create an array of customers. You can have up to 100 customers. Remember not to use magic numbers.
If you have any more questions
please e-mail Blanca or
Matt Sharritt
Back
to homework page