Bank Account Sample

package bankprocess;

/**
 *
 * @author Nurhak
 */
public class BankProcess {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        BankAccount account = new BankAccount();
     
        account.setAccountNr(123456789);
        account.putMoney(3000);
        account.takeMoney(1500);
     
        System.out.println("Total amount of money: " + account.getTotal());
    }
}

package bankprocess;

/**
 *
 * @author Nurhak
 */
public class BankAccount {

    private int accountNr;
    private double total;

    public boolean takeMoney(double money) {
        if (money <= this.getTotal()) {
            this.setTotal(this.getTotal() - money);
            return true;
        } else {
            return false;
        }
    }

    public void putMoney(double money) {
        this.setTotal(this.getTotal() + money);
    }

    /**
     * @return the accountNr
     */
    public int getAccountNr() {
        return accountNr;
    }

    /**
     * @param accountNr the accountNr to set
     */
    public void setAccountNr(int accountNr) {
        this.accountNr = accountNr;
    }

    /**
     * @return the total
     */
    public double getTotal() {
        return total;
    }

    /**
     * @param total the total to set
     */
    public void setTotal(double total) {
        this.total = total;
    }
    
}

Comments

Popular posts from this blog

Solution for "Can not obtain Oracle client information from registry"

Solution for the fault: "System.Diagnostics.Process.Start is not working on IIS, but working on ASP.NET Development Server"

Getting Umbraco Content - IPublishedContent vs IContent vs Node vs Document