|
@@ -0,0 +1,58 @@
|
|
|
+package com.lovecoding.day10.oopex05;
|
|
|
+
|
|
|
+import com.lovecoding.day10.oop04Public.A;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ClassName: TestAccount
|
|
|
+ * Package: com.lovecoding.day10.oopex05
|
|
|
+ * Description:
|
|
|
+ *
|
|
|
+ * @Author 爱扣钉-陈晨
|
|
|
+ * @Create 2023/6/18 17:02
|
|
|
+ * @Version 1.0
|
|
|
+ */
|
|
|
+public class TestAccount {
|
|
|
+ /*
|
|
|
+ 写一个用户程序测试Account类。在用户程序中,创建一个账号为1122、余额为20000、年利率4.5%的Account对象。使用withdraw方法提款30000元,并打印余额。
|
|
|
+ 再使用withdraw方法提款2500元,使用deposit方法存款3000元,然后打印余额和月利率。
|
|
|
+
|
|
|
+ 提示:在提款方法withdraw中,需要判断用户余额是否能够满足提款数额的要求,如果不能,应给出提示。
|
|
|
+ 运行结果如图所示:
|
|
|
+ */
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Account account = new Account();
|
|
|
+ account.setId(1122);
|
|
|
+ account.setBalance(20000);
|
|
|
+ account.setAnnualInterestRate(4.5);
|
|
|
+
|
|
|
+ account.withdraw(2500);
|
|
|
+
|
|
|
+ account.deposit(3000);
|
|
|
+ //打印余额和月利率
|
|
|
+ System.out.println(account);
|
|
|
+
|
|
|
+ //get
|
|
|
+ System.out.println("余额"+account.getBalance() +"- 年率率:"+account.getAnnualInterestRate());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ CheckAccount checkAccount = new CheckAccount();
|
|
|
+
|
|
|
+ checkAccount.setId(1122);
|
|
|
+ checkAccount.setBalance(20000);
|
|
|
+ checkAccount.setAnnualInterestRate(4.5);
|
|
|
+ checkAccount.setOverdraft(5000);
|
|
|
+
|
|
|
+ checkAccount.withdraw(5000);
|
|
|
+
|
|
|
+ System.out.println(checkAccount);
|
|
|
+
|
|
|
+ checkAccount.withdraw(18000);
|
|
|
+
|
|
|
+ System.out.println(checkAccount);
|
|
|
+
|
|
|
+ checkAccount.withdraw(3000);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|