Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python 1. Create an abstract class named Temperature and save it into its own Temperature.py file. The class should have special method __init__: def

In Python

1. Create an abstract class named Temperature and save it into its own Temperature.py file. The class should have special method __init__:

def __init__(self, temperature)

that is used to create a Temperature object, setting its internal temperature numeric value.

It should also have a getTemperature() method that just returns self.__temperature.

It should also have the following abstract methods that throw a NotImplementedError:

__str__ - should return a string of the form "75 degrees Fahrenheit"

aboveFreezing - should return True if the temperature is above the freezing point

convertToFahren - returns a new Temperature object converted to degrees Fahrenheit

convertToCelsius - returns a new Temperature object converted to degrees Celsius

convertToKelvin - returns a new Temperature object converted to degrees Kelvin

2. Create subclasses Fahrenheit, Celsius and Kelvin each in their own .py file that inherit from Temperature and correctly implement the various methods of Temperature. For example, each subclass should have a __str__ method that returns a string like "75 degrees Fahrenheit" in the case of the Fahrenheit class.

The convert methods should do the proper conversion for that class, like Fahrenheit to Kelvin. For a meaningless conversion, like convertToFahren in the Fahrenheit class, just return self.getTemperature().

3. In a fifth .py file have your main program that tests all these classes. Name this file Lab11.py. This test program should create a list of Temperature objects that are a mix of each type. At a minimum, have a list with 3 objects in it, one of each subclass type. Loop through the list and print each one out, print out if each one is above freezing or not, and print out each one converted to Fahrenheit.

Feel free to do any other extra things in your test program.

Add comments to your program starting with your name at the top, then throughout your program to describe what you are doing. Be sure and make your calculations clear, giving your variables meaningful names. Also be sure to indent consistently throughout your program to make it more readable. Be sure you run this and test it a few times before submitting.

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago