1 PackageCom.hanqi;2 3 Public classAccount {4 5 String Zhanghao;6 7 DoubleCunkuanyue;8 9Account (String Zhanghao,DoubleCunkuanyue)Ten { One //Initialize A This. Zhanghao =Zhanghao; - This. Cunkuanyue =Cunkuanyue; - } the - //Deposit - //a method with no return value with parameters - voidCunkuan (DoubleQianshu) + { -System.out.println ("Saved" +Qianshu); + This. Cunkuanyue + =Qianshu; A } at - //Withdrawals - //a method with no return value with parameters - voidQukuan (DoubleQianshu) - { -System.out.println ("took" +Qianshu); in This. Cunkuanyue-=Qianshu; - } to //Check Balance + //methods with no parameters for return values - the DoubleGetyue () * { $ return This. Cunkuanyue;Panax Notoginseng } - the + Public Static voidMain (string[] args) A { theAccount AC =NewAccount ("123456", 1000); + -Ac.cunkuan (100); $SYSTEM.OUT.PRINTLN ("Query balance =" +Ac.getyue ()); $ -Ac.qukuan (300); -SYSTEM.OUT.PRINTLN ("Query balance =" +Ac.getyue ()); the - }Wuyi the}
Learn to practice Java Object-oriented deposit and withdrawal enquiry balance