The given incomplete object class contains the declaration of six attributes which describe the objRecords object - NSC Information Technology - Question 2 - 2017 - Paper 1
Question 2
The given incomplete object class contains the declaration of six attributes which describe the objRecords object.
NAMES OF ATTRIBUTES DESCRIPTION
fdctor Name of... show full transcript
Worked Solution & Example Answer:The given incomplete object class contains the declaration of six attributes which describe the objRecords object - NSC Information Technology - Question 2 - 2017 - Paper 1
Step 1
Write a constructor called Create which will assign values to the fdctor, initialised to zero.
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 create a constructor named Create, the following code should be used:
public void Create(String fdctor, String fdate, String fmediad, String followup) {
this.fdctor = fdctor;
this.fdate = fdate;
this.fmediad = fmediad;
this.followup = followup;
this.fpayment = 0; // Initialising payment to 0
this.fmed = 0; // Initialising medical aid to 0
}
Step 2
Write a method called FollowUpDate which will return the date the patient has to see the doctor again.
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
The FollowUpDate method can be defined as follows:
public String FollowUpDate() {
if (followup.equals("Yes")) {
LocalDate date = LocalDate.parse(fdate);
date = date.plusDays(7);
return date.toString();
} else {
return "No Follow-Up Appointment Needed";
}
}
Step 3
Write a mutator method called SetPayment which will receive the amount that was made and update the existing payment amount.
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The SetPayment method is implemented as:
public void SetPayment(double amount) {
this.fpayment += amount;
}
Step 4
Write a mutator method called SetMed which will receive the amount that was submitted to the medical aid.
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The SetMed mutator method can be written as:
public void SetMed(double amount) {
this.fmed += amount;
}
Step 5
Write a method called CompileString which returns information about the doctor.
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Sign up now to view full answer, or log in if you already have an account!
Answer
This code captures the patient’s information and randomizes the payment amount:
public void captureInfo() {
// Implement logic to capture the doctor's information,
// get system date etc.
double amount = Math.random() * (400 - 300) + 300;
if (fmediad.equals("Yes")) {
SetMed(amount);
} else {
SetPayment(amount);
}
// Show message box.
}
Step 7
Display total amount of cash for the day.
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
This code calculates and displays cash amount for the day:
public void displayStats() {
// Code to aggregate total payments and display
}