Define a class printaccount that models a printing account


Problem

Define a class PrintAccount that models a printing account. The constructor should take arguments name with the full name of the user, and username with the corresponding login name. These should be stored in attributes self. name and self. username. The constructor should also initialise attribute self. balance to 0.0. Further, PrintAccount should have a class variable unit cost specifying the charge for printing a sheet of paper; this should be set to 0.10 Define the following methods:

I. A method topup that takes an amount as its argument and increments the attribute self. balance by that amount.

II. A method release prints that takes a parameter n (the number of prints to be released) as its argument. The method should use unit cost to determine the cost of the n prints. If the balance is sufficient, the method should subtract this cost from self. balance and return n. Otherwise, it should determine the maximum number of sheets that the balance will cover and return that number, after reducing self. balance by the corresponding charge. Note that this may leave the user with some small credit that is insufficient to pay for any printout.

III. A method get balance that returns the current balance.

IV. A method get details that returns a dictionary with keys "name", "username" and "balance". The values associated with these keys should be the full name of the user, their corresponding login and balance of the account.

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Define a class printaccount that models a printing account
Reference No:- TGS03219999

Expected delivery within 24 Hours