ATM
Assignment #2
Download AMT.zip, unzip it into your Java workspace, and make sure it works. To help understand the program, you may run ATMMain.java.
The objective of this assignment is to evaluate the design of an existing object-oriented program (i.e., the ATM source code). For each problem, you must provide a detailed justification (i.e., why or why not). If necessary, you may use screenshots of the source code to illustrate your answers.
1. Class Design (30 points)
(a) Does each of the classes, ATM, Money, and Card, have a good class abstraction? (5 points for each)
(b) Consider the following variables in class SimulatedBank and related operations: ACCOUNT_NUMBER, WITHDRAWALS_TODAY, DAILY_WINTHDRAWAL _LIMIT, and BALANCE[]. How can you improve the design? (15 points)
2. Design by Contract (30 points)
Consider the precondition of method subtract in class Money:
public void subtract(Money amountToSubtract)
(a) Is this.cents - amountToSubtract.cents>=0 a demanding precondition of subtract? Does it violate the reasonable precondition principle or the precondition availability principle? (15 points)
(b) List all method calls of subtract in the ATM program and discuss whether each violates the condition amountToSubtract.cents>=0? You may need to inspect call hierarchies to determine whether the input of each call is safe. (15 points)
3. Class Invariant (30 points)
(a) For an object of ATM class, is it possible that switchOn is false and state=SERVING_CUSTOMER_STATE is true? Provide detailed justification of your answer based on the code. (15 points)
(b) Consider all constructors and setters (mutators) of Money class. For an object of Money class, is it possible that this.cents<0? (15 points)
4. Inheritance (10 points)
Is the class hierarchy of Transaction, Withdrawal, Transfer, Deposit, and Inquiry a good application of inheritance? The criteria should include module view vs type view, subcontracting (precondition/postcondition), and Liskov Substitution Principle