Assume you have been asked to use Equivalence Partitioning method to check the ATM machine login function regarding to PIN number validation. Here are some detailed requirements: Users must use valid ATM card and enter a correct PIN number to access their accounts. Otherwise, a rejection message will be displayed to them. Here are some specification descriptions relating to a valid PIN number. Each valid PIN number must be formed with letters (‘a’ to ‘z) and digitals Each PIN must include at least one up-case letter and one lower-case letter. Each PIN is acceptable if it includes one special chars from the following list: o !, #, @, $ The length of each valid PIN must be in the range from 8 to 12. Whenever an invalid PIN is entered, one of following messages will be displayed: “Incorrect Password” - This suggests that a PIN (entered by a user) is valid but not correct. “Invalidated Password”- This suggests that a PIN (entered by a user) is invalid. a) Please list your identified equivalence classes when you testing this function, and present them using a table (or a diagram). b) Based on these equivalence classes identify and present test cases in a table.
Assume you have been asked to use Equivalence Partitioning method to check the ATM machine
login function regarding to PIN number validation. Here are some detailed requirements:
Users must use valid ATM card and enter a correct PIN number to access their accounts. Otherwise, a
rejection message will be displayed to them.
Here are some specification descriptions relating to a valid PIN number.
Each valid PIN number must be formed with letters (‘a’ to ‘z) and digitals
Each PIN must include at least one up-case letter and one lower-case letter.
Each PIN is acceptable if it includes one special chars from the following list:
o !, #, @, $
The length of each valid PIN must be in the range from 8 to 12.
Whenever an invalid PIN is entered, one of following messages will be displayed:
“Incorrect Password” - This suggests that a PIN (entered by a user) is valid but not correct.
“Invalidated Password”- This suggests that a PIN (entered by a user) is invalid.
a) Please list your identified equivalence classes when you testing this function, and present them using a
table (or a diagram).
b) Based on these equivalence classes identify and present test cases in a table.
public class Customer {
String customerId;
String customerName;
String atmCardNumber;
String atmPin;
public Customer(String customerId, String customerName, String atmCardNumber, String atmPin){
this.customerId = customerId;
this.customerName = customerName;
this.atmCardNumber = atmCardNumber;
this.atmPin = atmPin;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getAtmCardNumber() {
return atmCardNumber;
}
public void setAtmCardNumber(String atmCardNumber) {
this.atmCardNumber = atmCardNumber;
}
public String getAtmPin() {
return atmPin;
}
public void setAtmPin(String atmPin) {
this.atmPin = atmPin;
}
}
public class PinValidator {
private String pin;
public PinValidator(String pin){
this.pin = pin;
}
public void validate(){
String regexp = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#?])(?=\\S+$).{6,10}$";
if(pin.matches(regexp))
System.out.println("Login Successful"); else System.out.println("Invalidated Password");
}
}
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class TestPin {
public static void main(String[] args){
Customer customerOne = new Customer("1", "John", "1234 5678 9812","Hes@322");
// Creating an user base of customers
List<Customer> listOfCustomers = new ArrayList<>();
listOfCustomers.add(customerOne);
// Add more customers to the user base as per requirement
// Can also use a database for maintaining the user base
System.out.println("Enter Card Number: ");
Scanner scannerOne = new Scanner(System.in);
String cardNumber = scannerOne.nextLine();
for(Customer customer : listOfCustomers){
if(customer.getAtmCardNumber().equals(cardNumber)){
System.out.println("Enter PIN: ");
String pin = scannerOne.nextLine();
if(customer.getAtmPin().equals(pin)){
PinValidator pinValidator = new PinValidator(pin);
pinValidator.validate();
break;
}
else{
System.out.println("Incorrect Password");
break;
}
}
else{
System.out.println("Invalid Card Number");
break;
}
}
}
}
The above program validates ATM pins entered by the user.
Here we have three classes - Customer, PinValidator and TestPin.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps