案例3-2

Posted Harper886’s Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了案例3-2相关的知识,希望对你有一定的参考价值。

代码

Blank类

public class Blank 
    private int total;

    public Blank() 
    

    public Blank(int total) 
        this.total = total;
    

    public void show() 
        System.out.println("当前的存款为:" + total);
    

    public void Withdraw_money(int num) 
        if (total < num) 
            System.out.println("余额不足无法取款!");
         else 
            System.out.println("成功取款" + num + "元");
            total -= num;
            System.out.println("当前的存款为:" + total);
        

    

    public void Save_money(int num) 
        System.out.println("成功存款" + num + "元");
        total += num;
        System.out.println("当前的存款为:" + total);


    


main方法

public class Demo01 
    public static void main(String[] args) 
        Blank one=new Blank(500);
        one.show();
        one.Save_money(1000);
        one.Withdraw_money(800);
    


JavaScript小案例-留言板案例

JavaScript小案例-留言板案例
JavaScript小案例-留言板案例

以上是关于案例3-2的主要内容,如果未能解决你的问题,请参考以下文章