code sample icon Sample Code

In the generated Java class, after the first line:

                               
package oracle.model.freightejb;
                            

Add the following import statements:

                               
import oracle.model.freight.BatchOrder;
import oracle.model.freight.CustomerCode;
import oracle.model.freight.FreightDestination;
                            

After the line:

                               
public class CalculateFreightBean {
                            

Add the following code:

private static final Double BASE_COST = 10D;

After the following code:

                               
public CalculateFreightBean() {
                                
}

Add the following business method code:

                               
public Double calculateFreightCost(BatchOrder order,
                                   FreightDestination destination,
                                   CustomerCode customer) {
  Double totalCost =
   BASE_COST + order.getOrderedQuantity() * destination.factor();
  Double discount = customer.calculateDiscount(totalCost);
  return totalCost - discount;
}
                            

Instead of typing the sample code, you can copy the code in this window and then paste it into the source editor.

Copyright © 1997, 2009, Oracle. All rights reserved.

false ,,,,,,,,,,,,,,,