Java about bank card functions

Bank cards are the cards we often use, and each bank card corresponds to a bank account.
The bank card contains the following 3 pieces of information:
username, password, and bank balance.
The bank card includes the following 3 functions:
1. Deposit money: deposit a specified amount of money in the card
2. Withdraw money: withdraw a specified amount of money from the card Money
3. Query the balance: Query and return the balance in the card Requirements: 1. Define a bank card class, and define appropriate member variables and member methods in the class according to the above content 2. Instantiate the two in the main function of the main
class bank cards, the initial information of the two cards is as follows:
(1) Bank card 1: user name Zhan, password 12345, initial balance 6,800 yuan
(2) Bank card 2: user name Li, password 54321, initial balance 8,200 yuan
3. In the main function of the main class, 2,000 yuan is withdrawn from bank card 1 and 3,200 yuan is deposited in bank card 2. The balances in the two bank cards are displayed separately.

CreateMain.java


package kl;

public class Main {
	public Main() {
		
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Yhk a1=new Yhk();
		a1.userName="Zhan";
		a1.passWorld="12345";
		a1.leave=6800;
		
		Yhk a2=new Yhk();
		a2.userName="Li";
		a2.passWorld="54321";
		a2.leave=8200;
		
		a1.leave-=2000;
		a2.leave+=3200;
		System.out.println(a1.leave);
		System.out.println(a2.leave);
		
	}

}

CreateYhk.java

package kl;

public class Yhk {
	String userName;
	String passWorld;
	int leave;
	public Yhk() {
		
	}
}

 

Guess you like

Origin blog.csdn.net/m0_63715487/article/details/127709134