1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package com.sf.javase.day07.homework;
- import java.text.BreakIterator;
- /**
- * 这是储蓄卡的类
- */
- public class DepositCard {
- private String id;//账户
- private Double balance; //余额
- public void withdraw(double money){
- if(money < 0){
- System.out.println("提示取款金额不能为负数");
- return;
- }
- if(money > balance){
- System.out.println("否则提示余额不足");
- return;
- }
- balance -= money;
- }
- public void save(double money){
- if(money < 0){
- System.out.println("存款不能为负数");
- return;
- }
- balance += money;
- }
- public String getInfo(){
- return "DepositCard{" +
- "id='" + id + '\'' +
- ", balance=" + balance +
- '}';
- }
- public DepositCard() {
- }
- public DepositCard(String id, Double balance) {
- this.id = id;
- this.balance = balance;
- }
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public Double getBalance() {
- return balance;
- }
- public void setBalance(Double balance) {
- this.balance = balance;
- }
- @Override
- public String toString() {
- return "DepositCard{" +
- "id='" + id + '\'' +
- ", balance=" + balance +
- '}';
- }
- }
|