zoukankan      html  css  js  c++  java
  • 简单应用单例模式

    进行参数传值及本类属性值调用

     public class TBalancesUtil {
    private double before_amount;
    private double fen_qi_amountAll;
    private double fen_qi_amount;
    private TBalances tBalances;
    private TBalances tBalancesNew;
    private TGrocery tGrocery;
    private String period_name;
    private int period_fen_qi_shu;

    public TBalancesUtil() {

    }

    private static class Inner {
    private static TBalancesUtil getInstance(TBalances tBalances, TBalances tBalancesNew, TGrocery tGrocery, String period_name, int period_fen_qi_shu) {
    return new TBalancesUtil(tBalances, tBalancesNew, tGrocery, period_name, period_fen_qi_shu);
    }
    }

    public static TBalancesUtil getSingle(TBalances tBalances, TBalances tBalancesNew, TGrocery tGrocery, String period_name, int period_fen_qi_shu) {
    return Inner.getInstance(tBalances, tBalancesNew, tGrocery, period_name, period_fen_qi_shu);
    }


    public TBalancesUtil(TBalances tBalances, TBalances tBalancesNew, TGrocery tGrocery, String period_name, int period_fen_qi_shu) {
    this.tBalances = tBalances;
    this.tBalancesNew = tBalancesNew;
    this.tGrocery = tGrocery;
    this.period_name = period_name;
    this.period_fen_qi_shu = period_fen_qi_shu;
    this.before_amount = MathUtil.multiply(MathUtil.multiply(tBalances.getServicemoney(), tGrocery.getFixed_rate(), tGrocery.getKeep_decimal()), tGrocery.getBefore_amount_rate(), tGrocery.getKeep_decimal());
    this.fen_qi_amountAll = MathUtil.multiply(MathUtil.multiply(tBalances.getServicemoney(), tGrocery.getFixed_rate(), tGrocery.getKeep_decimal()), tGrocery.getFen_qi_amount_rate(), tGrocery.getKeep_decimal());
    this.fen_qi_amount = MathUtil.divide(MathUtil.multiply(MathUtil.multiply(tBalances.getServicemoney(), tGrocery.getFixed_rate(), tGrocery.getKeep_decimal()), tGrocery.getFen_qi_amount_rate(), tGrocery.getKeep_decimal()), tBalances.getFen_qi_shu(), tGrocery.getKeep_decimal());
    }


    public TBalances firstMouth() {
    tBalancesNew.setId(tBalances.getId());
    tBalancesNew.setContnum(tBalances.getContnum());
    tBalancesNew.setAccount_time(tBalances.getAccount_time());
    tBalancesNew.setFen_qi_shu(tBalances.getFen_qi_shu());
    tBalancesNew.setServicemoney(tBalances.getServicemoney());
    tBalancesNew.setBefore_amount(before_amount);
    tBalancesNew.setDone_fen_qi_amount(fen_qi_amount);
    tBalancesNew.setRemained_fen_qi_shu(tBalances.getFen_qi_shu() - 1);
    tBalancesNew.setRemained_fen_qi_amount(fen_qi_amountAll - fen_qi_amount);
    tBalancesNew.setCreate_date(tBalances.getCreate_date());
    tBalancesNew.setPeriod_name(period_name);
    tBalancesNew.setFen_qi_amount(fen_qi_amount);
    tBalancesNew.setPeriod_fen_qi_amount(fen_qi_amount);
    tBalancesNew.setPeriod_fen_qi_shu(1);
    tBalancesNew.setContract_status(1);
    return tBalancesNew;
    }


    public TBalances lastMouth() {

    tBalancesNew.setId(tBalances.getId());
    tBalancesNew.setContnum(tBalances.getContnum());
    tBalancesNew.setAccount_time(tBalances.getAccount_time());
    tBalancesNew.setFen_qi_shu(tBalances.getFen_qi_shu());
    tBalancesNew.setServicemoney(tBalances.getServicemoney());
    tBalancesNew.setDone_fen_qi_amount(fen_qi_amountAll);
    tBalancesNew.setCreate_date(tBalances.getCreate_date());
    tBalancesNew.setBefore_amount(0.00);
    tBalancesNew.setRemained_fen_qi_shu(period_fen_qi_shu);
    tBalancesNew.setRemained_fen_qi_amount(0.00);
    tBalancesNew.setFen_qi_amount(MathUtil.subtract(fen_qi_amountAll, MathUtil.multiply(fen_qi_amount, (period_fen_qi_shu - 1), 2), 2));
    tBalancesNew.setContract_status(2);
    tBalancesNew.setPeriod_name(period_name);
    tBalancesNew.setPeriod_fen_qi_amount(MathUtil.subtract(fen_qi_amountAll, MathUtil.multiply(fen_qi_amount, (period_fen_qi_shu - 1), 2), 2));
    tBalancesNew.setPeriod_fen_qi_shu(period_fen_qi_shu);

    return tBalancesNew;
    }


    public TBalances middleMouth() {
    tBalancesNew.setId(tBalances.getId());
    tBalancesNew.setContnum(tBalances.getContnum());
    tBalancesNew.setAccount_time(tBalances.getAccount_time());
    tBalancesNew.setFen_qi_shu(tBalances.getFen_qi_shu());
    tBalancesNew.setServicemoney(tBalances.getServicemoney());

    tBalancesNew.setPeriod_fen_qi_shu(period_fen_qi_shu);
    tBalancesNew.setContnum(tBalances.getContnum());
    tBalancesNew.setAccount_time(tBalances.getAccount_time());
    tBalancesNew.setFen_qi_shu(tBalances.getFen_qi_shu());
    tBalancesNew.setDone_fen_qi_amount(MathUtil.multiply(period_fen_qi_shu, fen_qi_amount, 2));
    tBalancesNew.setServicemoney(tBalances.getServicemoney());
    tBalancesNew.setCreate_date(tBalances.getCreate_date());
    tBalancesNew.setBefore_amount(0.00);
    tBalancesNew.setRemained_fen_qi_shu(period_fen_qi_shu);
    tBalancesNew.setRemained_fen_qi_amount(MathUtil.subtract(fen_qi_amountAll, MathUtil.multiply(period_fen_qi_shu, fen_qi_amount, 2), 2));
    tBalancesNew.setFen_qi_amount(fen_qi_amount);
    tBalancesNew.setContract_status(tBalances.getContract_status());
    tBalancesNew.setPeriod_name(period_name);
    tBalancesNew.setPeriod_fen_qi_amount(fen_qi_amount);

    return tBalancesNew;
    }

    }
  • 相关阅读:
    Netty ByteBuf(图解之 2)| 秒懂
    【转】 RGB各种格式
    缺少动态库报错
    bug:进程可调用函数而子线程调用报错
    【转】 pthread设置线程的调度策略和优先级
    【转】 C++析构函数的作用和用法
    【转】 g++编译时对'xxxx'未定义的引用问题(undefined reference to)
    【转】 C语言文件操作详解
    【转】 H.264编码原理以及I帧B帧P帧
    【转】 strrchr()函数---C语言
  • 原文地址:https://www.cnblogs.com/Dream--/p/8478063.html
Copyright © 2011-2022 走看看