Amount baseAmount = _lineAmount > 0 ?

You are a developer working on a new customized form and are troubleshooting a defect on the form.

The form displays a summary for each line. The defect report says that the form shows the incorrect

summary for return order lines.

A display method provides the summary, and the method calls the following:

public str salesLineSummary(

SalesType _type,

str _orderNum,

ItemId _itemId,

Qty _lineQty,

Amount _lineAmount

)

{

Amount baseAmount = _lineAmount > 0 ? _lineAmount : -1 * _lineAmount;

str formattedAmount = num2Str(baseAmount, 10, 2, DecimalSeparator::Dot,

ThousandSeparator::Comma);

str summary;

switch (_type)

{

case SalesType::Sales:

summary = strFmt(‘Order %1 ordered %2 of %3 [Subtotal: %4]’,

_orderNum, _lineQty, _itemId, formattedAmount);

break;

case SalesType::ReturnItem:

summary = strFmt(‘RMA %1 expecting %2 of %3 for %4 credit’,

_orderNum, _lineQty, _itemId, formattedAmount);

default:

summary = strFmt(‘Journal %1: %2 of %3’, _orderNum, _lineQty,

_itemId);

}

return summary;

}

You need to fix the defect in the most efficient way possible.

Which modification should you make?
A . Remove the default block of code from the switch statement.
B . Add an If statement to the default block of code in the switch statement.
C . Exchange the SalesType::Sales with the SalesType::ReturnItem blocks of code in the switch
statement.
D . Add a break statement before the default block of code in the switch statement.

Answer: D

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments