Create a Account class that inherits the properties and behaviors of the Account
ID: 671164 • Letter: C
Question
Create a Account class that inherits the properties and behaviors of the Account class.
a data field, name (of type String), to store the name of the customer
a constructor that constructs an account with the specified name, id, and balance
a data field, transactions of type (ArrayList; i.e. ArrayList<Transaction>). The Transaction is defined asMembers
date: java.util.Date
type: char
amount: double
balance: double
description: String
Constructor
Transaction(type: char, amount: double, balance: double, description: double)
Methods
getters for date, type, amount, balance, and description
setters for date, type, amount, balance, and description
Create a NewATM class that extends ATM machine from the previous question.
Inside this code, your program will display a 0th option, titled, see Account History. this option is selected, it will display the withdraw and deposit historys for the associated account.
Explanation / Answer
import java.util.Scanner;
public class ATMTest
{
public static void main(String args[])
{
ATM myATM = new ATM();
int choice;
int debit;
int credit;
int balance;
double amount;
double methodOutput;
Scanner input = new Scanner(System.in);
do
{
System.out.println("1. Withdrawal");
System.out.println("2. Deposit");
System.out.println("3. Get Balance");
System.out.println("4. Exit");
System.out.println("4. Exit");
choice = input.nextInt();
if (choice == 1)
{
System.out.println("Enter the amount you want to withdraw, please: ");
choice = input.nextInt();
methodOutput = myATM.withdrawal(amount);
---> The arguments need to match. In the ATM class
withdrawl function is defined as withdrawal(double newBalance, double amount)
So you need to pass 2 arguments instead of one
--> invoke the function through the object created myATM.(functionName)
}
if (choice == 2)
{
System.out.println("Enter the amount you will deposit: ");
choice = input.nextInt();
methodOutput = myATM.deposit(amount);
--->Same as above
}
if (choice == 3)
{
System.out.println("The available amount of cash to take from me is: ");
}
if (choice == 4)
{
System.out.println("See ya later " + firstName + lastName);
--> variables firstname and lastname need to be declared before use.
}
} while (choice != 4);
}
}