Create java class that will become part of a larger program


Assignment

In this homework assignment, you will create Java class that will become part of a larger program for a bank. As part of this program, we need several different classes of objects that will be expected to interact with each other. Here is a list:

BankAccount: Simple bank accounts that maintain a balance, allow accessing of the balance, and allow updating of the balance. Each account must have a unique account number.

Customer: Customers that maintain accounts at the bank. Each customer needs a unique id number. Since customer privacy is important, the bank only retains the customer's name or alias.

Employee: Bank employees have a unique id number so that each employee can be identified. They also have a job type which can be used to control which accounts they can access.

Since this program is too large for any single student to write, I will ask you to only create 1 of the above classes. Details about each class will be outlined below. The class you are assigned to complete is based on the first letter of your last name. See the breakdown below:

BankAccount: A, D, G, J, M, P, Q, T,
Customer: B, E, H, K, N, R, U, W
Employee: C, F, I, L, O, S, V, X, Y, Z

Since you are not writing the entire program and are only completing a small part, you are expected to complete the tasks individually. Also the class that represents the program will be unavailable until all the other parts are completed, so you are also tasked with writing a program (a separate file) that tests each of the methods that you are assigned to write in the main method. Please call this program TestBankAccount, TestCustomer, or TestEmployee (whichever is appropriate for your assigned class).

Part A

Make a new folder within your unit5 folder called "bank". You do not use a package name for any of your files, simply keep everything in the default package. This will allow me to test your code easier upon submission. (This shouldn't really matter unless you are using some additional extensions for Java.)

Within this folder you should make your files. You should have two files depending upon which part of the project you are working on. Here is a reminder of the list:

BankAccount.java, TestBankAccount.java
Customer.java, TestCustomer.java
Employee.java, TestEmployee.java

Part B

Update each of the code segments according to the tasks lists below. A brief description of each task has been included here for each class. Make sure that you follow the description for your assigned class. They are displayed below.

Task I

First, make a new class called Customer (in a file called Customer.java). This class represents a customer at a bank. This customer's personal information stored is very limited. Only the customer's name is maintained and this name may be an alias. Instead the bank uses ID numbers to identify the customer and account associated with the customer.

Make a JavaDoc comment at the top of the class before writing any code within it. Include in the JavaDoc a description of the class. Change the @author tag to indicate your name as the programmer. Add the @version tag so that it includes the date that the program was created (today).

Task II

Create the attributes that every Customer should have. As you make each attribute add a JavaDoc comment that describes the attributes.

Each Customer instance should have an id number, and a name. Be sure to use appropriate data types for each attribute and the correct access modifier. All attributes in our Bank class should be fully encapsulated and not accessible from outside the class.

The Customer class should also have a shared attribute: the next id number to be created. Call this attribute nextID. The first id number should be set to 9999.

Task III

Produce a method called advanceNextID that allows the next id number (the shared attribute) to be advanced by adding one to the number. This method should be only accessible from within the class and should be a shared method.

Document this method using a JavaDoc.

Task IV

Make 2 constructors for the Customer class that allow the customer to be created in two different ways: a default customer and a customer that has a name.

The default constructor: this constructor should set the customer's name to "Anonymous" and should assign the id number using the shared attribute (see above).

For the other constructor, the caller of the method will provide the name. The name should contain at least 3 characters (you do not need to enforce this). The id number should be set in the same way as the other constructor.

For both constructors, be sure that you call the advanceNextID method after setting the customer's id number. This should ensure that the next id number is properly set.

Document both constructors using a JavaDoc. Be sure to add preconditions about the limitations of the parameter.

Task V

Produce a toString method for the Customer class such that the details about the customer can be displayed to the console when printed. The output should appear similar to the output in the example below with the customer's name as the last part of the text. Make sure the spacing is correct. You should not put a newline at the end.

CUSTOMER# 9999: Anonymous

Task VI

Make getter methods for all instance attributes inside the class. These getters should allow for external access of the private data that is inside the class without giving access to change the values of these attributes. You should have 2 methods that all start with the name "get" after completing this task.

Make sure that you also document each getter using a JavaDoc. These JavaDoc should be relatively short, but still descriptive.

Task VII

Make one setter method for the class that allows the name of the customer to be updated. Your method should just replace the new name with the given name. However, it should not allow the name to be set if the new name contains fewer than 3 characters.

Make sure that you also document the setter using a JavaDoc. These JavaDoc should be relatively short, but still descriptive. Include the postconditions as appropriate that describe what should happen when a valid update of the attribute occurs.

Part C

Task VIII

Writing an additional class (in a separate file) that tests each of the methods that you are assigned to write. Please call this program TestBankAccount, TestCustomer, or TestEmployee (whichever is appropriate for your assigned class). This class should contain a main method that tests your class.

Task IX

Your test class should test the other class that you made by instantiating at least 2 objects...

• Make 1 object using the default constructor to make sure it compiles correctly.
• Make the other object using the parameterized constructor to make sure it compiles correctly.
• Test each object to see if the id or account number is properly set.
• Test 1 object to see if it correctly uses the setter to change the value.
• Test 1 object to see if it doesn't update the value if a invalid value is used.
• Test the toString method for at least 1 object.
• Label each of the tests with a comment that includes the test number.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Create java class that will become part of a larger program
Reference No:- TGS03284796

Expected delivery within 24 Hours