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

Class Diagram The Store class has a list of customers and a list of computers th

ID: 3553353 • Letter: C

Question

Class Diagram

The Store class has a list of customers and a list of computers that can be organized at the store. The store will be a fully encapsulated object. The Store class implements the Serializable interface.
It has the following attributes:

Attribute name

Attribute type

Description

customerList

ArrayList or Vector

A list of customers in the store

computerList

ArrayList or Vector

A list of computers in the store

The following public methods should be provided to interact with the store:

Method

Description

Store()

A Constructor of the Store class. The ArrayLists/Vectors of customerList and computerList are instantiated.

int customerExists(String)

Search for a customer by customer ID and return the index of the object if found. Return -1 if not found. The parameter is the customer ID of a customer.

boolean addCustomer(String)

Add a customer to the customer list. Return true if the customer was added successfully. Return false if the customer with the same customer ID already exists (the customer is not added). The parameter is the string to be parsed by the CustomerParser.

boolean removeCustomer(String)

Remove a customer from the customer list. Return true if the customer was removed successfully. Return false if the customer with the given customer ID does not exist. The parameter is the customer ID of a customer.

void sortCustomers()

Sort the list of customers by last name from A to Z. If more than one customer has the same last name, compare their first names. This method calls the sort method defined in the Sorts class.

String listCustomers()

List all customers in the customer list. The returned string is the concatenation of each customer object information in the list. Hint: you can utilize customer's toString method to help you complete this method. If there is no customer in the list, This method should return the string containing "no customer ".

int computerExists(String brandName, String cpuType, int cpuSpeed, int memory)

Search for a computer in the computer list. Return the index of the computer object if the computer object of the same brand name, cpuType, cpuSpeed, and memory is found. Return -1 if not found. The parameters are the brand name (String), the cpuType (String), the cpuSpeed (int), and the memory (int) of the computer to be searched.

boolean addComputer(String)

Add a computer to the computer list. Return true if the computer was added successfully. Return false if the computer already exists based on the criteria in the computerExists method (the computer is not added in this case). The parameter is the string to be parsed by the ComputerParser.

boolean removeComputer(String brandName, String cpuType, int cpuSpeed, int memory)

Remove a computer from the computer list. Return true if the computer of the given brand name, cpuType, cpuSpeed, and memory was removed successfully. Return false if the computer does not exist. The parameters are the brand name (String), cpuType (String), cpuSpeed (int) and memory (int) of the computer to be removed.

void sortComputers()

Sort the list of computers. If more than one computer has the same brand name, compare their cpu using the compareTo method of the CPU class. If they have the same cpu, compare their memory. This method calls the sort method defined in the Sorts class.

String listComputers()

List all computers in the computer list. The returned string is the concatenation of each computer object information in the list. Hint: you can utilize computer's toString method to help you complete this method. If there is no computer in the list, it should return the string containing "no computer "

void closeStore()

Closes the store by making all lists empty. This can be done by using clear() method of the ArrayList.

No input/output should occur in the store. User interaction should be handled only by the driver class. Customers will be uniquely identified by their customer ID, computers will be uniquely identified by the combination of their brand name, cpuType, cpuSpeed, and memory. This might not a realistic assumption, but it will make the project easier to implement.

You may add other methods to the class in order to make your life easier

Attribute name

Attribute type

Description

customerList

ArrayList or Vector

A list of customers in the store

computerList

ArrayList or Vector

A list of computers in the store

Explanation / Answer

Find the code here : http://ideone.com/2l9k1u