Question: Need help to answer the question in JAVA (Object-oriented programming) Given the following hierarchy of superclass Patient and their subclasses; Inpatient and Outpatient and the

 Need help to answer the question in JAVA (Object-oriented programming) Given

the following hierarchy of superclass Patient and their subclasses; Inpatient and Outpatient

Need help to answer the question in JAVA (Object-oriented programming)

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(), getRefIDO, getMalaysia () //tostring() - return information about the object public abstract double calcost(); //abstract method } Subclass: Inpatient public class Inpatient 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 Out Patient extends Patient { { private String medicineType; 1ormal or special private final double consult Fee = 30.0; = //Methods: /ormal constructor //accessors; getMediType() //toString() - return information about the object public double calcost() { method definition } } a) 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 out Patient, 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. (9 marks)

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!