ATM系统的类实现详解
1. 引言
在ATM系统的设计与实现中,各个类承担着不同的功能,共同协作完成ATM的各项操作。下面将详细介绍ATM系统中各个类的具体实现。
2. 键盘类(Keypad)
2.1 功能概述
Keypad
类代表ATM的键盘,用于获取用户输入的整数。
2.2 代码实现
// Keypad.java
// Represents the keypad of the ATM
import java.util.Scanner; // program uses Scanner to obtain user input
public class Keypad {
private Scanner input; // reads data from the command line
// no-argument constructor initializes the Scanner
public Keypad() {
input = new Scanner(System.in);
} // end no-argument Keypad constructor
// return an integer value entered by user
public int getInput() {
return input.nextInt(); // we assume that user enters an integer
} //