void printOwing(double previousAmount)
{
Enumeration e = _orders.elements();
double outstanding = previousAmount * 1.2;
// print banner
System.out.println ("**************************");
System.out.println ("***** Customer Owes ******");
System.out.println ("**************************");
// calculate outstanding
while (e.hasMoreElements()) {
Order each = (Order) e.nextElement();
outstanding += each.getAmount();
}
//print details
System.out.println ("name:" + _name);
System.out.println ("amount" + outstanding);
}
que pasa de la forma que se puede ver en el archivo de moonEdit extract method archive
a ser el siguiente código
void printOwing(double previousAmount)
{
printBanner();
printDetails(calculateOutstanding(previusAmount*1.2));
}
void printBanner()
{
System.out.println ("**************************");
System.out.println ("***** Customer Owes ******");
System.out.println ("**************************");
}
void printDetails(Double outstandingArg)
{
System.out.println ("name:" + _name);
System.out.println ("amount" + outstandingArg);
}
Double calculateOutstanding(Double previousValue)
{
Double result = previousValue;
Enumeration e = _orders.elements();
while (e.hasMoreElements()) {
Order each = (Order) e.nextElement();
outstanding result += each.getAmount();
}
return result;
}
No hay comentarios:
Publicar un comentario