Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class PhonePlan: . def init_ (self, type, 1ines use an empty list as its initial value. Create an instance ved by any line of this

image text in transcribed
class PhonePlan: . def init_ (self, type, 1ines use an empty list as its initial value. Create an instance ved by any line of this plan, initialize it to be an empty list -None): create/initialize instance variables for type and the list of create/init lines in the plan. When lines is not provided, emp variable calls to keep a list of calls made/received any Also create instance variables rollover_mins def_str_(self): create/return a string similar to or balance, rollover_mins, and mins_ to_pay, all starting at zero PhoneP1an(PlanType(25.50, 200, e.se, True). See test cases for example more examples. Hint: when obtaining strings for the lists of lines/calls, how can you rely er str or repr definitions to make this a short/trivial method to wri er-repr(self): create/return a string identical to the_str output def activate all(self): mak e sure every line in this plan is active after calling this method. e sure every line in this plan is inactive after calling this method. add call (self, call): add the given call to the end of the list of calls. Either caller or callee of call should be a line of this plan, otherwise do not append but raise a PhonePlanError with error mssgeall cannot be added". If call can be added, check whether the call is billable based on the following rules A local call is free and not billable; Hint: use your Call class's is local method to help. A call made between two lines of this plan is free and not billable o For a billable call, increment instance variable mins to pay based on the length of the call. All updates made in this method change instance variables directly and the method ret urns None. e def remo call): remove the given call from the list of calls and returns None. If call is self, calls): accept a list of calls, use add call() to add each to the end of the list elp ve_call(self, not present in the list, raise a PhonePlanError with error messag e "no such_call_to_remove e def add_calls(self, accept of calls and update mins_to_pay accordingly. Count and return the number of calls that are successfully added into the call record. Requirement and Hint: you must call add_call; exception handling can h def make_call(self, caller, callee, length): create a call based on caller, callee, and length then add it to the end of the list of calls and update mins_to_pay accordingly. Return True if the call is created and added successfully; return False if The call cannot be created due to a CallError; or The call cannot be added due to a PhonePlanError (neither caller nor callee belongs to this plan). o o def mins by_line(self, line): calculate and return the number of call minutes associated with the given line in this plan based on the current list of calls. A call is associated with a line if the line is eith its caller or callec. Return zero if the given line is not included in this plan. Hint: Make sure your Line lass'seq_ method works, first. class PhonePlan: . def init_ (self, type, 1ines use an empty list as its initial value. Create an instance ved by any line of this plan, initialize it to be an empty list -None): create/initialize instance variables for type and the list of create/init lines in the plan. When lines is not provided, emp variable calls to keep a list of calls made/received any Also create instance variables rollover_mins def_str_(self): create/return a string similar to or balance, rollover_mins, and mins_ to_pay, all starting at zero PhoneP1an(PlanType(25.50, 200, e.se, True). See test cases for example more examples. Hint: when obtaining strings for the lists of lines/calls, how can you rely er str or repr definitions to make this a short/trivial method to wri er-repr(self): create/return a string identical to the_str output def activate all(self): mak e sure every line in this plan is active after calling this method. e sure every line in this plan is inactive after calling this method. add call (self, call): add the given call to the end of the list of calls. Either caller or callee of call should be a line of this plan, otherwise do not append but raise a PhonePlanError with error mssgeall cannot be added". If call can be added, check whether the call is billable based on the following rules A local call is free and not billable; Hint: use your Call class's is local method to help. A call made between two lines of this plan is free and not billable o For a billable call, increment instance variable mins to pay based on the length of the call. All updates made in this method change instance variables directly and the method ret urns None. e def remo call): remove the given call from the list of calls and returns None. If call is self, calls): accept a list of calls, use add call() to add each to the end of the list elp ve_call(self, not present in the list, raise a PhonePlanError with error messag e "no such_call_to_remove e def add_calls(self, accept of calls and update mins_to_pay accordingly. Count and return the number of calls that are successfully added into the call record. Requirement and Hint: you must call add_call; exception handling can h def make_call(self, caller, callee, length): create a call based on caller, callee, and length then add it to the end of the list of calls and update mins_to_pay accordingly. Return True if the call is created and added successfully; return False if The call cannot be created due to a CallError; or The call cannot be added due to a PhonePlanError (neither caller nor callee belongs to this plan). o o def mins by_line(self, line): calculate and return the number of call minutes associated with the given line in this plan based on the current list of calls. A call is associated with a line if the line is eith its caller or callec. Return zero if the given line is not included in this plan. Hint: Make sure your Line lass'seq_ method works, first

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

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions