Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE THANK YOU SIR/MADAM I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE THANK YOU SIR/MADAM I NEED THE

image text in transcribedI NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE

THANK YOU SIR/MADAM

I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE

THANK YOU SIR/MADAM

I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE

THANK YOU SIR/MADAM

I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE

THANK YOU SIR/MADAM

I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE

THANK YOU SIR/MADAM

I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE

THANK YOU SIR/MADAM

I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE

THANK YOU SIR/MADAM

I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE

THANK YOU SIR/MADAM

I NEED THE CODE IN PHYTON PROGRAMMING LANGUAGE

THANK YOU SIR/MADAM

Case Study Il: Software Engineering with Abstract Classes and Abstract Methods Abstract Base Class Patient-The Python Standard Library's abc (abstract base class) module helps you Each patient, regardless of the way his or her payments are calculated, has a first name, a last name and that can be used to create objects are called concrete classes. calculation depends on the patient's type, so you'll make payments an abstract method that the subclasses must override. Your Patient class should contain: Abstract Classes-Now, let's consider class TwoDimensionalShape in the Shape hierarchy's second level. If we were to create a TwoDimensionalShape object and call its draw method, class i. An__init_ method that initializes the first name, last name and Social Security number data TwoDimensionalshape knows that all two-dimensional shapes are drawable, but it does not know attributes. what specific two-dimensional shape to draw-there are many! So, it does not make sense for ii. Read-only properties for the first name, last name and Social Security number data attributes. TwoDimensionalShape to fully implement a draw method. A method that is defined in a given class, iii. An abstract method payment preceded by the abc module's @abstractmethod decorator. but for which you cannot provide an implementation is called an abstract method. Any class with an Concrete subclasses must implement this method. The Python documentation says you should abstract method has a "hole" -the incomplete method implementation-and is called an abstract raise a NotlmplementedError in abstract methods. class. TypeErrors occur when you try to create objects of abstract classes. In the Shape hierarchy, iv. A _repr_ method that returns a string containing the first name, last name and Social classes Shape, TwoDimensionalShape and ThreeDimensionalShape all are abstract classes. They all Security number of the patient. know that shapes should be drawable, but do not know what specific shape to draw. Abstract base Concrete Subclass RegularPatient-This Patient subclass should override payments to return a classes are too general to create real objects. RegularPatient's weekly payment. The class also should include: Inheriting a Common Design-An abstract class's purpose is to provide a base class from which i. An _init_method that initializes the first name, last name, Social Security number and subclasses can inherit a common design, such as a specific set of attributes and methods. So, such weekly salary data attributes. The first three of these should be initialized by calling base class classes often are called abstract base classes. In the Shape hierarchy, subclasses inherit from the Patient's _init_method. abstract base class Shape the notion of what it means to be a Shape-that is, common properties, such as location and color, and common behaviors, such as draw, move and resize. ii. A read-write weekly_payment property in which the setter ensures that the property is always Polymorphic Cost of a Patient System-Now, let's develop an Patient class hierarchy that begins with non-negative. an abstract class, then use polymorphism to perform cost calculations for objects of two concrete iii. A _repr__method that returns a string starting with ' RegularPatient:' and followed by all the subclasses. Consider the following problem statement: information about a RegularPatient. This overridden method should call Patient's version. 1. A patient pays to the healthcare institution weekly. The patients are of two types: i) Regular Concrete Subclass InstantPatient-This Patient subclass should override payments to return an patients pay a fixed weekly payment regardless of the number of hours passed in the healthcare InstantPatient's payments, based on the hours passed and payment per hour. The class also should institution. Instant patients pay by the hour and in addition to an overtime pay ( 1.5 times their include: hourly payment rate) for all hours passed in excess of 40 hours in a week. The healthcare institution i. An _init__method to initialize the first name, last name, Social Security number, hours and wants to implement an app that performs its income calculations polymorphically. payment data attributes. The first name, last name and Social Security number should be initialized by calling base class Patient's __init__ method. Patient Hierarchy Class Diagram-The following diagram shows the Patient hierarchy. Abstract class ii. Read-write hours and payment properties in which the setters ensure that the hours are in Patient represents the general concept of a patient. Subclasses RegularPatient and InstantPatient range (0168) and payment per hour is always non-negative. inherit from Patient. iii. A _repr__ method that returns a string starting with InstantPatient:' and followed by all the information about a Instant Patient. This overridden method should call Patient's version. Testing Your Classes-In an IPython session, test your hierarchy: 1. Import the classes Patient, RegularPatient and InstantPatient. 2. Attempt to create a Patient object to see the TypeError that occurs and prove that you cannot create an object of an abstract class. 3. Assign objects of the concrete classes RegularPatient and InstantPatient to variables, then display each patient's string representation and payments. 4. Place the objects into a list, then iterate through the list and polymorphically process each object, displaying its string representation and payments

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_2

Step: 3

blur-text-image_3

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

Students also viewed these Databases questions