Object-oriented-deposit and withdrawal

Source: Internet
Author: User

1String Zhanghu;//Define Account2    DoubleCunkuanyue;//Define Deposit Balances3Account (String Zhanghu,DoubleCunkuanyue)//Initialize account, deposit balance4    {5        //This . Represents the current class6         This. zhanghu=Zhanghu;7         This. cunkuanyue=Cunkuanyue;8    }9    //DepositTen    //methods with parameters for return values One     DoubleCunkuan (DoubleQianshu) A     { -         //Validation -         if(Qianshu < 1)  the         { -SYSTEM.OUT.PRINTLN ("Input Error"); -  -         }  +         Else -         { +System.out.println ("Saved" +Qianshu); A              This. Cunkuanyue + =Qianshu; at         } -         return  This. Cunkuanyue; -     } -     -  -     in  //Withdrawals -    //methods with parameters for return values to     DoubleQukuan (DoubleQianshu) { +         if(Qianshu > This. Cunkuanyue) { -SYSTEM.OUT.PRINTLN ("Insufficient balance"); the  *}Else { $System.out.println ("took" +Qianshu);Panax Notoginseng              This. Cunkuanyue-=Qianshu; -         } the         return  This. Cunkuanyue; +     } A    //Check Balance the    //methods with no parameters for return values +    DoubleGetyue () -    { $        return  This. Cunkuanyue; $    } -      -      the      Public Static voidMain (string[] args) { -         //TODO Auto-generated method stubsWuyiAccount account=NewAccount ("123456", 1000); theAccount.cunkuan (100); -System.out.println ("Check balance" +Account.getyue ()); WuAccount.qukuan (300); -System.out.println ("Check balance" +Account.getyue ()); About}

Object-oriented-deposit and withdrawal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.