Question: Please help me solve this question. Thank You! [Object-oriented programming] [Java] Question: p/s: using Java Given the following hierarchy of superclass Patient and their subclasses;

Please help me solve this question. Thank You! [Object-oriented programming] [Java]

Please help me solve this question. Thank You! [Object-oriented programming] [Java] Question:

Question:

p/s: using Java Given the following hierarchy of superclass Patient and their

p/s: using Java

Given the following hierarchy of superclass Patient and their subclasses; Inpatient and Outpatient and the definition for each superclass and subclasses Superclasss: Loan public abstract class Patient { protected String name; protected long refid; protected boolean isMalaysia; /ame of patient //reference number //true for Malaysia //Methods: /ormal constructor //accessors; getName(), getRefID(), getMalaysia () //toString() - return information about the object public abstract double calCost(); //abstract method } Subclass: InPatient public class In Patient extends Patient { { private String roomType; // room type private int numDay; /umber of days warded //Methods: /ormal constructor //accessors; getRoom(), getNumDay() //toString() - return information about the object public double calCost() { method definition } } Subclass: Outpatient public class Outpatient extends Patient { { private String medicineType; /ormal or special private final double consultFee = 30.0; //Methods: /ormal constructor //accessors; getMediType() //toString() - return information about the object public double calCost() { method definition } } Write the method definition of calCost() for both subclasses to calculate and returns the total cost that each patient has to pay based on the given information. For subclass inpatient, the cost will be based on the following table: Type of Room Diamond Gold Silver Bronze Price/Day (RM) 200.00 100.00 80.00 50.00 The non-Malaysian patient need to be paid an extra RM50 per day For subclass outpatient, the cost depends on: Medicine type given, if the medicine type is normal, the cost is RM30 else the cost is RM80. The consultation fee needs to be added to the total cost. For Malaysian, the discount of 15% will be given out of the total cost

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!