Object Oriented programming Python...
We would like to model a mug/cup as a cylindrical vessel with an open top. The mug will have a fixed total capacity (the volume of a cylinder, C=PI*r**2*h), and at any given time a certain amount of liquid will be in it (varying from 0 to C) at a certain temperature. Thus, the state of the cup at any given time can be represented by four parameters, its radius, height, current volume of liquid and the temperature of the liquid. Write a class in python to represent the mug. The class should have...
1)A constructor (__init__) to create a mug of a certain radius and height. By default set the volume of liquid in the mug to be zero at the start, and its temperature to be 20 degrees.
2)A method that returns the volume of liquid currently in the mug. (Note: All lengths should be in centimetres, and volumes in milliliters: 1 cubic centimetre equals 1 milliliter.)
3)A method that returns the capacity of the mug.
4)A method that tells the user "how full" (in percentage terms) the cup is.
5)A method that adds a certain volume (say V1) of liquid at a certain temperature (say T1). If there is currently some (other) liquid volume V2 in the mug at temperature T2, you should set the final liquid temperature to be (V1*T1 + V2*T2)/(V1 + V2). If the volume of liquid being added does not fit in the cup, you should of course warn the user (and... let them chose between cancelling the operation or just filling it to capacity).
6)A method that removes ("pours out") a certain volume of liquid from the mug (again... if the volume requested for removal is greater than the current volume, the user should have the option of cancelling the operation or emptying all the mug).
7)A "fill to brim" method that fills the mug to its capacity (with the same liquid/temperature as is currently in the mug). This method must call the method you have written in (5.).
All your methods, the constructor, and the class itself, should have appropriate docstrings. You should test your methods well (by calling them from the main program), to make sure they work as planned.
Make sure the programme...
It runs without crashing
Its tested on many different kinds of input
It gets the right answer
It has (lots of) comments
Variable and function names are well chosen and meaningful
There is no redundant code or variables
It is as efficient as possible (no repeated/unnecessary calculations)
Code listing is short if possible
User interaction (input/output) is helpful/user friendly