Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are writing a small section of an ATM machine where you accept a string that is a password and accept it or reject it.

You are writing a small section of an ATM machine where you accept a string that is a password and accept it or reject it. If the user tries more than three times with a bad password the card is blocked and no password will be accepted until the resetPasswordAttempts method is called. The password must be fixed at "1234". Security is a priority!

The object to implement this is referred to as AtmPin and consists of the following public methods:

public AtmPin(String actualCode) - Creates an AtmPin object with the provided code as the actual PIN

public boolean verifyPinCode(String code) - Accepts a string which represents the password attempt. If the string matches the actual code provided in the constructor then the method returns true. Returns false when the code is bad OR when isBlocked() is true due to too many consecutive bad password attempts.

public boolean isBadPassword() - True when a bad pin is passed to acceptPinCode. Updated every time a password is passed to verifyPinCode. Note that you can have a good password but it is not accepted by the system (verifyPinCodereturns false) since the password is blocked.

public boolean isBlocked() - If more than three consecutive attempts are made then the password is not accepted (verifyPinCode returns false) until resetPasswordAttempts is called.

public void resetPasswordAttempts() - Resets the number of attempts to zero.

Your Program.java should contain code to test your AtmPinobject. Be sure to test the cases where you are blocked and send it a good password. It should still reject the password but isBadPassword will return false.

Getting Started

We are going to do this exercise by writing the object that solves the problem first (in a source file called AtmPin.java) and then testing it using code we write into Program.java. Using the techniques shown on the web page titled "How to Start Every Project in this Class" create a source file called AtmPin.java as well as a file called Program.java.

Starting this week we don't have any code to copy for the assignment. You get to do it all! Don't forget to provide proper Javadoc documentation.

Your Program.java should contain code to test your AtmPin object. The test code for this project can be quite complex. Be sure to test the case where you get good passwords, bad passwords, and when you're locked out.

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

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions