Question: Create a class named CellPhonePlan that extends the PhonePlan class and represents a cell phone plan for a cell phone. This class comes with all
Create a class named CellPhonePlan that extends the PhonePlan class and represents a cell phone plan for a cell phone. This class comes with all the functionality of the basic PhonePlan with the added ability to track the total and currently consumed SMS messages within the plan. The class is designed with the following properties and methods:
Properties:
maxmessages: The maximum number of messages the plan allows at any time. This represents the starting total of messages available to the user at the beginning of the plan's billing cycle.
messages: The total number of messages consumed. This is calculated as maxmessages
def initself network:dict, minutes:int, messages:int:
Initializes a new PhonePlan instance with a specified network, minutes, and messages.
Args:
network dict: A dictionary mapping phone numbers to phone objects.
minutes int: The total minutes provided by the plan.
messages int: The total SMS messages provided by the plan.
def sendmessageself phonenumber:str:
Sends a message, reducing either plan's available message count by one for a successfully sent and received message.
Check if the other phone has enough messages before sending the message by checking the message property of the
other phone's phone plan. Keep in mind the other phone may not have a plan. If the other phone does not have a plan,
consider it as if it has enough messages to receive a message.
Args:
phonenumber str: The phone number to send the message to
Raises:
RuntimeError: If either phone does not have enough messages left or if the phone number is not in the network.
NotImplementedError: If the receiving phone cannot receive messages.
def resetself:
Resets the plan's minutes and messages properties to their maximum values.
This method does not require arguments as it resets the plan's minute and message counts to maxminutes and
maxmessages respectively.
Make sure you include the PhonePlan class code in your submitted code. Example:
class PhonePlan:
class CellPhonePlanPhonePlan:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
