Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will develop classes called ATM(Driver class) and Customer that simulate an imaginary automated teller machine (ATM). In the assignment, you should also develop a

You will develop classes called ATM(Driver class) and Customer that simulate an imaginary automated teller machine (ATM). In the assignment, you should also develop a UML class diagram for the ATM class.

NOTE: NEED A DRIVER IN ONE OF THE CLASSES

In the program, we assume that an ATM initially keeps $100.00 cash for customer transactions. Additionally, we assume that there are total ten customers combined for the OUBank and BOA banks. This is a list of customers with their names, PINs, balances, and banks they have.

Alice, 1234, $5000.00, OUBank

Tom, 2000, $200.00, OUBank

Monica, 3000, $50.00, OUBank

Michael, 7777, $0.00, OUBank

John, 8000, $500.00, OUBank

Jane, 2222, $500.00, OUBank

Robert, 2323, $200.00, BOA

Owen, 4455, $50.00, BOA

Chris, 8787, $10.00, BOA

Rebecca, 8080, $555.55, BOA

Demo Program

The following program presents a demo program that uses the ATM and Customer classes.

public class ATMDemo

{

public static void main(String[] args)

{

ATM machine1 = new ATM(OUBank);

ATM machine2 = new ATM(200, BOA, Library);

Customer alice;

System.out.println("===== Welcome to Demo Program =====");

System.out.println(machine1); System.out.println();

System.out.println(machine2);

System.out.println(" ===== Equality Checking =====");

System.out.println(machine1.equals(machine2));

System.out.println();

machine1.setATM(100, BIT);

machine1.addFund(400);// In this method, we assume that an ATM machine

// administrator adds $400 more cash to the machine.

System.out.println(machine1);

System.out.println();

machine1.displayMenu()

machine1.withdrawal(Alice, 7777, 10.50); // In the method, we assume

// that the customer Alice wants $10.50 withdrawal with PIN 7777.

machine1.withdrawal(Robert, 2323, 10.50);

machine1.withdrawal(Alice, 1234, 10000);

machine1.withdrawal(Alice, 1234, 10);

machine1.withdrawal(Alice, 1234, 2000);

System.out.println(" ===== Machine Status =====");

machine1.status();

System.out.println();

if (machine1.isCustomer(Alice)) {

alice = machine1.getCustomer(Alice);

System.out.println(alice);

System.out.println();

}

machine1.deposit(Alice, 1234, 10); // In the method, we assume that

// Alice conducts the cash deposit $10

// to the machine with PIN 1234.

System.out.println(" ===== Machine Status =====");

machine1.status();

System.out.println();

//The following method conducts a money transfer transaction from

// Alice to Tom about $10.00 dollars.

if (machine1.transfer(Alice, 1234, 10, Tom, 2000)) {

System.out.println("Good transfer!!! ");

}

if (!machine1.transfer(Chris, 8787, 10, Tom, 2000)) {

System.out.println("Bad transfer!!! ");

}

System.out.println(" ===== Machine Status =====");

machine1.status();

System.out.println(" ===== Thank you! ====="); } }

Sample Run of the Demo Program

The following presents a sample result of the demo program.

===== Welcome to Demo Program =====

Serial Number: 0

Bank Name: OUBank

Location: UNKNOWN

Balance: 100.00

Serial Number: 200

Bank Name: BOA

Location: Library

Balance: 100.00

===== Equality Checking =====

false

Serial Number: 100

Bank Name: OUBank

Location: BIT

Balance: 500.00

===== ATM Transaction Menu =====

1. Withdrawal

2. Deposit

3. Transfer

Fail withdrawal

Fail withdrawal

Fail withdrawal

Succeed withdrawal

Fail withdrawal

===== Machine Status =====

Serial Number: 100

Bank Name: OUBank

Location: BIT

Balance: 490.00

5 Transactions so far:

Withdrawal: 5 (1 success, 4 fail)

Deposit: 0 (0 success, 0 fail)

Transfer: 0 (0 success, 0 fail)

Alice: Balance $4990.00

Succeed deposit

===== Machine Status =====

Serial Number: 100

Bank Name: OUBank

Location: BIT

Balance: 500.00

6 Transactions so far:

Withdrawal: 5 (1 success, 4 fail)

Deposit: 1 (1 success, 0 fail)

Transfer: 0 (0 success, 0 fail)

Succeed transfer

Good transfer!!!

Fail transfer

Bad transfer!!!

===== Machine Status =====

Serial Number: 100

Bank Name: OUBank

Location: BIT

Balance: 500.00

8 Transactions so far:

Withdrawal: 5 (1 success, 4 fail)

Deposit: 1 (1 success, 0 fail)

Transfer: 2 (1 success, 1 fail)

===== Thank you! =====

Read the demo program and sample execution result very carefully to identify operations of the classes. And also, you should consider the failure cases of the transactions such as incorrect name, incorrect PIN, not enough fund, unmatched bank, etc.

UML Design

Based on the demo program and sample run, identify instance variables and methods for the ATM class and draw the class in a UML class diagram using the Visio program (or other tools). In the UML diagram, you should include all instance variables and methods that are necessary to run the demo program. But you dont need to include constructors, accessors, and mutators because they are obvious. And also, you dont need to draw the UML diagram for the Customer class because its very small. You should convert the ATM class diagram to a PDF file and submit it on the iLearn. If you submit a different format, you will get zero credit for the UML portion.

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

ISBN: 0130913677, 978-0130913678

More Books

Students also viewed these Databases questions