Details:
You will implement the following UML
You have two classes (two different files/tabs in eclipse) to write in
this lab. Both are fairly straightforward, they represent a very much
simplified bank application.
Each of the methods you need to write are outlined below
- In the Customer class
- the Customer constructor will take its three parameters and
initialize the three instance variables. Don't forget that taxID is
deliberately shadowed, you'll need to use keyword this to get around the shadowing.
- toString should be implemented as discused in class. Give the
name of the class, the instance variable names and a string
representation of each instance variable.Return this string representation to the caller.
- getSavingsAcct should return the SavingsAccount instance variable
- equals should return true if the two customers have the same
data (including equal savings accounts). This method should return
false otherwise.
- In the BankAccount Class
- The BankAccount constructor should take a double and initialize
the balance instance variable with it. For now initialize isTaxable to
true by default.
- toString should be implemented as discused in class. Give the name of the class,
the instance variable names and a string representation of each
instance variable. Return this string representation to the caller.
- equals should check content equality to see if the balance and taxable attributes of the two BankAccounts are the same.
Here is the File I'll use to test your code:
=====================begin java file===============================
public class Lab6{
public static void main(String[] args){
Lab6 myLab = new Lab6();
myLab.testAll();
}
public void testAll(){
//create some variables to work with;
BankAccount Savings1 = new BankAccount (3453.67);
BankAccount Savings2 = new BankAccount (3453.67);
BankAccount Savings3 = new BankAccount (345.67);
BankAccount Savings4 = Savings2;
String Name = "Ted";
Customer cust1 = new Customer(Savings1, 1231, Name);
Customer cust2 = new Customer(Savings2, 1231, "Ted");
Customer cust3 = new Customer(Savings3, 1231, "Sara");
Customer cust4 = new Customer(Savings4, 1231, Name);
//now lets test your methods
System.out.println("testing toString methods");
//this might print out something like: Customer with TaxID 1231, Name: Ted and Savings1: BankAccount with Balance: 3452.67 and isTaxable of true (I orignanally said false but its been pointed out that I did ask you to initialize isTaxable)
System.out.print("cust1:");
System.out.println(cust1);
//this next one will print out the same as above
System.out.print("cust2:");
System.out.println(cust2);
System.out.print("cust3:");
//this might print out something like: Customer with TaxID 1231, Name: Sara and Savings1: BankAccount with Balance: 345.67 and isTaxable of
true (I orignanally said false but its been pointed out that I did ask you to initialize isTaxable)
System.out.println(cust3);
System.out.print("cust4:");
System.out.println(cust4);
System.out.println("testing equals methods:");
System.out.print("Savings1.equals(Savings2):");
System.out.println(Savings1.equals(Savings2));//should be true
System.out.print("Savings2.equals(Savings4):");
System.out.println(Savings2.equals(Savings4));//should be true
System.out.print("custs2.equals(cust4):");
System.out.println(cust2.equals(cust4)); //should be true
System.out.print("custs1.equals(cust4):");
System.out.println(cust1.equals(cust4)); //should be true
System.out.print("custs1.equals(cust3):");
System.out.println(cust1.equals(cust3)); //should be false
}
}
========================end java file======================
Additinal restrictions:
To help you get in the habit of good program writing, I am imposing the
following additional restrictions on your program.
- You must comment your code. We are starting to get to the point
where you are writing longer programs and doing more on your own. you
will need to start commenting your code so that both you and I know
what you are trying to do. To this end credit in the assignment will be
reservedfor grading your comments.
- Add a readme.txt file as a text file in your submission. Your
readme file should contain
- your name
- a brief (one paragraph) description of how
you implemented the project,
- anything that is left undone in the project.
Submitting:
again zip up your project folder and submit it to me by email.
Make sure that your submitted zip file
contains your first initial and last name as part of the zip file name.