Question: Create a class named PhonePlan that represents a standard phone plan for a cell phone. This class encapsulates information about the phone network, associates phone
Create a class named PhonePlan that represents a standard phone plan for a cell phone. This class encapsulates information about the phone network, associates phone numbers with phones through a dictionary, and tracks the total and currently consumed minutes within the plan. The class is designed with the following properties and methods:
Properties:
network: The phone network this plan is part of
maxminutes: The maximum number of minutes the plan allows at any time. This represents the starting total of minutes available to the user at the beginning of the plan's billing cycle.
minutes: The total number of minutes remaining to be consumed. This is calculated as maxminutes
def initself network:dict, minutes:int:
Initializes a new PhonePlan instance with a specified network, minutes, and messages.
Args:
network dict: A dictionary mapping phone numbers to phone objects. A Phone object may or may not have a property named plan which represents a PhonePlan.
minutes int: The total minutes provided by the plan.
def makecallself totalminutes:int, phonenumber:str:
Attempts to make a call, deducting the specified number of minutes from either plan's current total for a successful call.
Check if the other phone has enough minutes before making the call by checking the minutes 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 the other phone has enough minutes to make the call.
Args:
totalminutes int: The total number of minutes the call will take.
Raises:
RuntimeError: If either phone does not have enough minutes for the call or if the phone number is not in the network.
def resetself:
Resets the plan's minutes property to its maximum values.
This method does not require arguments as it resets the plan's minute count to maxminutes
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
