Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 3: Contracts As we saw earlier, the starter code includes a Contract class in contract.py, which contains a basic set of attributes and methods.

Task 3: Contracts As we saw earlier, the starter code includes a Contract class in contract.py, which contains a basic set of attributes and methods. Each contract contains at the very least a start date and a Bill object. We are making some simplifying assumptions: regardless of the contract type, the billing cycle starts on the 1st of the month and ends on the last day of the month. incoming calls are free. for any given contract type, the rate charged for a minute is always the same. In other words, all contracts of the same type charge the same rate per minute, but different contract types may charge different rates. The interaction between contracts and bills is something you have to piece together carefully, so we will give you some guidance to see the big picture, as follows: whenever a new month is encountered in the historic data from the input dataset, we advance to a new month of contract all customers and all phone lines. You did this already in application.py, by calling the new_month() function from that module in the process_event_history(), whenever the timestamp of an event indicates a new month is encountered. given that historic records get loaded gradually, the bill attribute of a contract always represents the latest bill (the one for the month we are currently loading events for). Once the data is fully processed, the bill is basically corresponds to the last month encountered in the input data. notice that the contract instance has the information on how much a call should be charged, whether a call should be free or billed, etc. Therefore, you must ensure that each monthly bill can get this information, whenever you advance the month. To understand the interaction between contracts and bills, ask yourself these questions: is this the first month of the contract? do you get new free minutes for the contract type? how do you handle billing a call? what is specific to each contract type? Your task: implement classes for each of the three types of customer contracts: month-to-month, term, and prepaid. The new classes must be called MTMContract, TermContract, and PrepaidContract respectively. To prepare for this task, you need to do two things: First, review all the variables we have provided in module contract that store predefined rates and fees. You must not modify these. Then, make sure you understand the Bill class, defined in module bill. Pay particular attention to methods set_rates() and add_fixed_cost(). They will be important when you need to create a new monthly bill. Task 3.1: Implement term contracts A term contract is a type of Contract with a specific start date and end date, and which requires a commitment until the end date. A term contract comes with an initial large term deposit added to the bill of the first month of the contract. If the customer cancels the contract early, the deposit is forfeited. If the contract is carried to term, the customer gets back the term deposit. That is, if the contract gets cancelled after the end date of the contract, then the term deposit is returned to the customer, minus that months cost. The perks of the term contract consist of: having a lower monthly cost than a month-to-month contract lower calling rates, and a number of free minutes included each month, which refresh when a new month starts. Free minutes are used up first, so the customer only gets billed for minutes of voice time once the freebies have been used up. To prepare, have a look over the TERM_DEPOSIT fee defined in contract.py, as well as the corresponding rate per minute of voice time. You can assume that the bill is paid on time each month by the customer, so you dont have to worry about carrying over the previous months bill for a Term Contract. It is important to note that a customer in a Term Contract can continue with the same contract past its end date (at the same rate and conditions), and can do so until the contract is explicitly cancelled. When the term is over (and the contract hasnt been cancelled), instead of adding a new term deposit and refunding the old one, the deposit simply gets carried over and does not get refunded until the contract gets cancelled. Your task: Implement class TermContract as a subclass of Contract. The TermContract methods must follow the same interface as the Contract class. Consider each aspect of a term contract carefully! Task 3.2: Implement month-to-month contracts The month-to-month contract is a Contract with no end date and no initial term deposit. This type of contract has higher rates for calls than a term contract, and comes with no free minutes included, but also involves no term commitment. Have a look at contract.py for all the rates per minute for each type of contract. Just like for a Term Contract, you can assume that the bill is paid on time each month by the customer, so you dont have to worry about carrying over an unpaid bill. Your task: Implement the MTMContract class as a subclass of Contract. The MTMContract class methods must follow the same interface as the Contract class. Consider each aspect of this contract carefully! Task 3.3: Implement prepaid contracts A prepaid contract has a start date but does not have an end date, and it comes with no included minutes. It has an associated balance, which is the amount of money the customer owes. If the balance is negative, this indicates that the customer has this much credit, that is, has prepaid this much. The customer must prepay some amount when signing up for the prepaid contract, but it can be any amount. When a new month is started, the balance from the previous month gets carried over into the new month, and if there is less than a $10 credit left in the account, the balance must get a top-up of $25 in credit (again, keep in mind that a negative amount indicates a credit). When cancelling the contract, if the amount left is forfeited. If the balance is positive, this should be returned by the cancel_contract() method, so that an application can notify the customer about a remaining balance to be paid (although our application does not do this). Your task: Implement the PrepaidContract class as a subclass of Contract. The PrepaidContract class methods must follow the same interface as the Contract class. Consider each aspect of this contract carefully!

bill file

image text in transcribed

image text in transcribed

image text in transcribed

contract file

image text in transcribed

image text in transcribed

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

Building The Data Warehouse

Authors: W. H. Inmon

4th Edition

0764599445, 978-0764599446

More Books

Students also viewed these Databases questions

Question

Presentation Aids Practicing Your Speech?

Answered: 1 week ago