Question: Create a project called Example 1. You will then write three classes: Create a new CustomerList object Prompt the user to enter a file name

Create a project called Example 1. You will then write three classes:

Create a new CustomerList object

Prompt the user to enter a file name

Call the getCustomerList() method with the file name that the user entered

While(true){

Prompt user to enter command;

if(command is "a"){

Prompt user for the customerNumber firstName lastName balance;

Create a customerRecord and store it in the database;

} else if (command is "f"){

Prompt the user to enter a customer number and then displays the corresponding record on the screen;

} else if (command is "q"){

Prompt the user to enter a file name to save the latest updates;

Save the information in the database to the file specified by the user;

Terminate program;

}else {

Display error message;

}

}

customerList.java - This class contains an array of customerRecord objects. It should have the following data attributes and methods:

private int count - number of customers in the array

private customerRecord[]data - array of customerRecord objects

public void getCustomerList(String fileName) - reads a file call fileName which is a text file containing lines (record) of customer data. This method fills the data array with the records from the file. The file will not have more than records and will have the following format (where customerNumber is an integer, fileName and lastName are Strings, and balance is a float:

customerNumber firstName lastName balance

public customerRecord getCustomer(int customerNumber) - returns the object corresponding to the customer with customer number customerNumber. If the customer number is not in the array, return null.

public void enterCustomerRecord(customerRecord new_record) - store the customer record into data array

public void saveCustomerList(String fileName) - save the information stored in the data array to the file called filename

customerRecord.java - a class that contains the following data attributes and methods:

private int customerNumber - a unique number assigned to each customer

private String firstName - the customer's first name

private String lastName - the customer's last name

private float balance - the customer's balance

get/set Methods for each data attribute

public String toString() - Special method to be used when printing a customerRecord object

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!