码迷,mamicode.com
首页 > 其他好文 > 详细

0925-练习

时间:2016-09-25 22:01:44      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

 1 public class Account {
 2     
 3     private double balance;
 4 
 5     public Account(double balance)
 6     {
 7         this.balance=balance;
 8     }
 9     public double getBalance() {
10         System.out.println("当前余额为:"+balance+"元");
11         return balance;
12     }  
13     public double deposit(double add){
14         balance+=add;
15         System.out.println("存钱"+add+"元,当余额为"+balance+"元");
16         return balance;
17     }  
18     boolean    withdraw(double get){
19         if(get<=balance)
20         {
21             System.out.println("取钱"+get+"元,当余额为"+balance+"元");
22             return true;
23         }
24         else
25         {
26             System.out.println("‘余额不足");
27             return false;
28         }        
29     }

 

0925-练习

标签:

原文地址:http://www.cnblogs.com/jingfengling/p/5906974.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!