Question: Please help me solve this question. Thank You! [Object-oriented programming] [Java] p/s: using Java Given the following hierarchy of superclass Patient and their subclasses; Inpatient
Please help me solve this question. Thank You! [Object-oriented programming] [Java]
![Please help me solve this question. Thank You! [Object-oriented programming] [Java] p/s:](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f92e162d2cb_29366f92e1598718.jpg)
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 } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
