The MidCity Shopping Centre sells gift vouchers that can be used at any shop in the shopping centre - NSC Information Technology - Question 3 - 2021 - Paper 1
Question 3
The MidCity Shopping Centre sells gift vouchers that can be used at any shop in the shopping centre. The minimum amount available per gift voucher card is R50 and th... show full transcript
Worked Solution & Example Answer:The MidCity Shopping Centre sells gift vouchers that can be used at any shop in the shopping centre - NSC Information Technology - Question 3 - 2021 - Paper 1
Step 1
3.1. Write code to do the following:
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To complete this section, first, we need to extract the required values from the form:
Extract Values:
Retrieve the gift voucher number from edt03_VoucherNum.
Get the customer's name from edt03_2_1.
Capture the selected amount from cmb03_2_1.
Instantiate Object:
Create a new object of the class objGiftVoucher using the constructor:
objGiftVoucher = new GiftVoucher(giftVoucherNumber, customerName, selectedAmount);
Display Details:
Use the toString method to display information in the output area red03_2_1:
red03_2_1.setText(objGiftVoucher.toString());
Step 2
3.2. Write code to do the following:
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Retrieve Voucher Number:
Fetch the gift voucher number entered in edt03_VoucherNum.
Check if it matches the object’s voucher number using getVoucherNumber.
Get Balance:
If they match:
Call getBalance() on objGiftVoucher to get the balance and display it in the panel pnl03_2_2.
Enable the button btn03_2_b.
Usage of Gift Voucher:
For using the voucher, get the purchase amount from user input.
Verify with isSufficient(Purchase) method:
If true, call updateBalance method and show success message: "Voucher successfully used".
If false, calculate outstanding balance and display a failure message with the outstanding amount in pnl03_2_2.