Create a new Java class in your NetBeans project named InvoiceItem
.
Add the three fields from the class diagram to the class.
Generate getters and setters for the fields using <
Insert Code > Getter and Setter">>. Select all three fields and click <>. Note that the insert code feature is context sensitive --- you need to have the cursor inside the class, between the two curly brackets or you will not see the <> option.Add the getItemTotal
method. It should multiply the salePrice
with the quantityPurchased
and return the result.
If your code is looking a bit messy then format it using <
Format">>.