package com.thoughtworks.refactoring.replaceTempwithQuery;

/**
 * Created by xinzhang on 6/27/17.
 */
public class Product {
    private String name;
    private int purchasePrice;

    public Product(String name) {
        this.name = name;
    }

    public void setPurchasePrice(int purchasePrice) {
        this.purchasePrice = purchasePrice;
    }

    public String getName() {
        return name;
    }

    public int getPurchasePrice() {
        return purchasePrice;
    }

    public double calcSellingPrice() {
        int rate = this.purchasePrice <= 100 ? 3 : 2;
        return this.purchasePrice * rate;
    }
}

@@ -530,18 +530,14 @@
     
-int rate =
+return
  thi
@@ -556,23 +556,71 @@
 ice 
-%3C= 100 ? 3 : 2;
+* calcSellingRate();%0A    %7D%0A%0A    private int calcSellingRate() %7B
 %0A   
@@ -654,14 +654,22 @@
 ice 
-* rate
+%3C= 100 ? 3 : 2
 ;%0A  

Replace Temp With Query - Replace temp variable with query method.