package com.thoughtworks.refactoring.ReplaceMethodWithMethodObject;

/**
 * Created by yzeng on 07/08/2017.
 */
public class Gamma {
    private UserAccount userAccount;
    private int inputValue;
    private int quantity;
    private int yearToDate;
    private int tempValue1;
    private int tempValue2;
    private int tempValue3;

    public Gamma(UserAccount userAccount, int inputValue, int quantity, int yearToDate) {
        this.userAccount = userAccount;
        this.inputValue = inputValue;
        this.quantity = quantity;
        this.yearToDate = yearToDate;
    }

    public int compute() {
        tempValue1 = (inputValue * quantity) + userAccount.Delta;
        tempValue2 = (inputValue * yearToDate) + 100;
        if (yearToDate - tempValue1 > 100)
            tempValue2 -= 20;
        tempValue3 = tempValue2 * 7;
        return tempValue3 - 2 * tempValue1;
    }
}

@@ -629,52 +629,194 @@
 1 = 
-(inputValue * quantity) + userAccount.Delta;
+getTempValue1();%0A        tempValue2 = getTempValue2();%0A        tempValue3 = getTempValue3();%0A        doSomething();%0A        return finalCompute();%0A    %7D%0A%0A    private int finalCompute() %7B
 %0A   
@@ -812,32 +812,39 @@
 ute() %7B%0A        
+return 
 tempValue2 = (in
@@ -840,44 +840,67 @@
 alue
-2 = (inputValue * yearToDate) + 100;
+3 - 2 * tempValue1;%0A    %7D%0A%0A    private void doSomething() %7B
 %0A   
@@ -973,32 +973,67 @@
 20;%0A    
+%7D%0A%0A
     
-tempValue3 =
+private int getTempValue3() %7B%0A        return
  tempVal
@@ -1049,46 +1049,192 @@
     
+%7D%0A%0A
     
-return tempValue3 - 2 * tempValue1
+private int getTempValue2() %7B%0A        return (inputValue * yearToDate) + 100;%0A    %7D%0A%0A    private int getTempValue1() %7B%0A        return (inputValue * quantity) + userAccount.Delta
 ;%0A  

refactor Gamma class