Photo AI

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 icon

Question 2

The-given-incomplete-object-class-contains-the-declaration-of-six-attributes-which-describe-the-objRecords-object-NSC Information Technology-Question 2-2017-Paper 1.png

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

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

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

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

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

Answer

The CompileString method can be structured as:

public String CompileString() {
    if (followup.equals("Yes")) {
        return "Doctor: " + fdctor + "; Follow-up needed: Yes";
    } else {
        return "Doctor: " + fdctor + "; No Follow-Up Appointment Needed";
    }
}

Step 6

Capture Info Button

97%

121 rated

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

Answer

This code calculates and displays cash amount for the day:

public void displayStats() {
    // Code to aggregate total payments and display
}

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;