JAVA: Debit Card Reader (interfaces) "CashRegister.java" is the ONLY FILE the can be edited!!!! No other files that are given below can be edited!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$^$%&%^&$%^ Many machines are able to make use of debit cards in order for people to make transactions using the money in their bank accounts. One piece of a debit card's security is its PIN number, which must be entered correctly for a transaction to proceed. The main() program below defines a cash register and a debit card with the pin 1234, and then accepts a PIN number as input. The entered PIN number is passed to the cash register along with the debit card object to verify that the entered PIN was correct. Given main(), a DebitCard class, and a DebitCardReader interface, complete the definition for the CashRegister class. The CashRegister class should provide a definition for the abstract method from the interface it implements. The program will be complete once this abstract method is defined correctly. Ex. If the input is: 1234 the output should be: Transaction succeeded! If the input is: 1111 the output should be: Transaction failed. Templet files: Transaction.java import java.util.Scanner; public class Transaction { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); CashRegister register = new CashRegister(); DebitCard card = new DebitCard(1234); int pin; pin = scnr.nextInt(); if (register.verifyCardPIN(card, pin)) { System.out.println("Transaction succeeded!"); } else { System.out.println("Transaction failed."); } } } DebitCard.java public class DebitCard { private int pin; public DebitCard(int newpin) { pin = newpin; } public int getPIN() { return pin; } public void setPIN(int newpin) { pin = newpin; } } DebitCardReader.java public interface DebitCardReader { public boolean verifyCardPIN(DebitCard card, int pin); } CashRegister.java public class CashRegister implements DebitCardReader {

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

JAVA: Debit Card Reader (interfaces)

"CashRegister.java" is the ONLY FILE the can be edited!!!! No other files that are given below can be edited!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$^$%&%^&$%^

Many machines are able to make use of debit cards in order for people to make transactions using the money in their bank accounts. One piece of a debit card's security is its PIN number, which must be entered correctly for a transaction to proceed. The main() program below defines a cash register and a debit card with the pin 1234, and then accepts a PIN number as input. The entered PIN number is passed to the cash register along with the debit card object to verify that the entered PIN was correct.

Given main(), a DebitCard class, and a DebitCardReader interface, complete the definition for the CashRegister class. The CashRegister class should provide a definition for the abstract method from the interface it implements. The program will be complete once this abstract method is defined correctly.

Ex. If the input is:

1234

the output should be:

Transaction succeeded!

If the input is:

1111

the output should be:

Transaction failed.
 
 
Templet files: 
Transaction.java

import java.util.Scanner;

public class Transaction {
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      
      CashRegister register = new CashRegister();
      DebitCard card = new DebitCard(1234);
      
      int pin;
      
      pin = scnr.nextInt();
      
      if (register.verifyCardPIN(card, pin)) {
         System.out.println("Transaction succeeded!");
      }
      else {
         System.out.println("Transaction failed.");
      }
   }
}

DebitCard.java

public class DebitCard {
   private int pin;
   
   public DebitCard(int newpin) {
      pin = newpin;
   }
   
   public int getPIN() {
      return pin;
   }
   
   public void setPIN(int newpin) {
      pin = newpin;
   }
}

DebitCardReader.java

public interface DebitCardReader {
   public boolean verifyCardPIN(DebitCard card, int pin);
}

CashRegister.java

public class CashRegister implements DebitCardReader { 

Expert Solution
steps

Step by step

Solved in 6 steps with 6 images

Blurred answer
Knowledge Booster
Random access
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education