Created
September 13, 2019 05:24
-
-
Save shekhargulati/6317ce920f931cac37b62d0af675d926 to your computer and use it in GitHub Desktop.
Refactoring Example 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
public class OrderService { | |
void print(List<Order> list, String n) { | |
double outstanding = 0.0; | |
System.out.println("*****************************"); | |
System.out.println("****** Customer Outstanding Total ******"); | |
System.out.println("*****************************"); | |
for (Order o : list) { | |
outstanding += o.getAmount(); | |
} | |
System.out.println("name: " + n); | |
System.out.println("amount: " + outstanding); | |
} | |
} | |
class Order { | |
private double amount; | |
public Order(double amount) { | |
this.amount = amount; | |
} | |
public double getAmount() { | |
return amount; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment