Skip to content

Instantly share code, notes, and snippets.

@shekhargulati
Created September 13, 2019 05:24
Show Gist options
  • Save shekhargulati/6317ce920f931cac37b62d0af675d926 to your computer and use it in GitHub Desktop.
Save shekhargulati/6317ce920f931cac37b62d0af675d926 to your computer and use it in GitHub Desktop.
Refactoring Example 1
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