Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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]

image text in transcribed

Question:

image text in transcribed

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 } } Assume that the following array of object had been declared: Patient[ ] pn = new Patient [50]; Write a Java application class that uses the concept of polymorphism to perform the following tasks: i) Calculate and display the total cost made by every patient for each subclass, Inpatient and Out Patient 5 ) (5 marks) ii) Count the number of patients that warded in the platinum room type, display the respective information about every patient in the platinum room and the total platinum room based on counter. (6 marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Write the actions down. And do them!

Answered: 1 week ago