Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYthon: 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,

IN PYthon: 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. Extra Credit: For 5 points of extra credit, get the user involved in your test program. That is, prompt the user to add as many Temperature objects as they would like in some kind of loop. For example: Please enter a temperature decimal value: 32 Please enter a temperature decimal value: 100 Please enter a temperature decimal value: 99 Please enter a temperature decimal value: 1 Please enter a temperature decimal value: 0 Please enter a temperature decimal value: quit - Temperatures in Fahrenheit, Celsius and Kelvin - 32.0 degrees Fahrenheit 32.0 degrees Celsius(above freezing) 32.0 degrees Kelvin 100.0 degrees Fahrenheit(above freezing) 100.0 degrees Celsius(above freezing) 100.0 degrees Kelvin 99.0 degrees Fahrenheit(above freezing) 99.0 degrees Celsius(above freezing) 99.0 degrees Kelvin 1.0 degrees Fahrenheit 1.0 degrees Celsius(above freezing) 1.0 degrees Kelvin 0.0 degrees Fahrenheit 0.0 degrees Celsius 0.0 degrees Kelvin - Temperatures converted to Fahrenheit - 32.0 degrees Fahrenheit 89.6 degrees Fahrenheit 305.1 degrees Fahrenheit 100.0 degrees Fahrenheit 212.0 degrees Fahrenheit 373.1 degrees Fahrenheit 99.0 degrees Fahrenheit 210.2 degrees Fahrenheit 372.1 degrees Fahrenheit 1.0 degrees Fahrenheit 33.8 degrees Fahrenheit 274.1 degrees Fahrenheit 0.0 degrees Fahrenheit 32.0 degrees Fahrenheit 273.1 degrees Fahrenheit Please submit your program in the DropBox area by midnight on Monday, November 13. Upload your actual .py files, I will run it on my computer. Be sure you have tested it first to make sure it runs with no errors and then does what you expect. You will only receive credit for the parts of the program that run successfully. This program is worth 15 points (20 if you also complete the extra credit). Please submit this program as Temperature.py, Fahrenheit.py, Celsius.py, Kelvin.py and Lab11.py.

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions