Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 11th International Symposium Sstd 2009 Aalborg Denmark July 8 10 2009 Proceedings Lncs 5644

Authors: Nikos Mamoulis ,Thomas Seidl ,Kristian Torp ,Ira Assent

2009th Edition

3642029817, 978-3642029813

More Books

Students also viewed these Databases questions