Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do not post the same code as currently on chegg ty Phython only implement two classes in Python: B asicAccount and P remiumAccount. The

Please do not post the same code as currently on chegg ty

Phython only

implement two classes in Python: BasicAccount and PremiumAccount.

The classes are to be adherent to the following UML Class diagram, though you may add extra methods and variables if you wish (essentially, the class diagram is a minimum, and it shows you what will be tested against):

To read the UML diagram, a line of : means that varName is an object of that data type.

A line of : means that the method will return a particular data type.

The variables of the classes are described as follows:

  • name the account holders name

  • acNum the number of the account. This should be serial, as in the first account to be created should be number 1, the second account to be created should be 2, and so on...

  • balance The balance (in pounds) of the account.

  • CardNum The card number should be a string of a 16 digit number (you should use the random module for this)

  • cardExp - a tuple where the first element is an int of the month and the second element is 2-digit year. Eg: 03/23 represents March 2023 (You should use the datetime module for this)

  • overdraft True if the account has an overdraft, and false if not

  • overdraftLimit The amount that the account can go overdrawn by

The method behaviours are as follows:

  • __init__(self, str, float)

    Initialiser giving the account name and opening balance

  • __init__(self, str, float, float) initialiser giving the account name, opening balance, and overdraft limit (0 or above)

  • deposit(self, float) Deposits the stated amount into the account, and adjusts the balance appropriately. Deposits must be a positive amount.

  • withdraw(self, float) Withdraws the stated amount from the account, prints a message of has withdrew . New balance is . If an invalid amount is requested, then the following message should be printed, and the method should then terminate: Can not withdraw

  • getAvailableBalance(self) Returns the total balance that is available in the account as a float. It should also take into account any overdraft that is available.

  • getBalance(self) returns the balance of the account as a float. If the account is overdrawn, then it should return a negative value.

  • printBalance(self) Should print to screen in a sensible way the balance of the account. If an overdraft is available, then this should also be printed and it should show how much overdraft is remaining.
  • getName(self) Returns the name of the account holder as a string

  • getAcNum(self) Returns the account number as a string

  • issueNewCard(self) Creates a new card number, with the expiry being 3 years to the month from now. (eg: if today is 3/12/20, then the expiry date would be (12/23))

  • closeAccount(self) To be called before deleting of the object instance. Returns any balance to the customer (via the withdraw method) and returns True. Returns False if the customer is in debt to the bank, and prints message Can not close account due to customer being overdrawn by Clarification: You shouldnt actually delete the account instance.... this function will simply do the relevant house keeping in the account, and return a boolean

  • setOverdraftLimit(self, float) Sets the overdraft limit to the stated amount

In addition to the above, you must also define suitable string representations that give the account name, available balance, and overdraft details (that is: you need to also implement the __str__ methods for each class).

image text in transcribed

+ BasicAccount + name : string + acNum : int + balance : float + cardNum : string + cardExp : tuple(int,int) _init__(self : BasicAccount, acName : string, openingBalance : float) str (self : BasicAccount) : string + deposit(self : BasicAccount, amount ; float) + withdraw(self : BasicAccount, amount : float) + getAvailableBalance(self : BasicAccount) : float + getBalance(self : BasicAccount) : float + printBalance(self : BasicAccount) + getName(self : BasicAccount) : string + getAcNum(self : BasicAccount) : string + issueNewCard(self : BasicAccount) + closeAccount(self : BasicAccount) : boolean PremiumAccount + overdraft : boolean + overdraftLimit : float + _init_(self : PremiumAccount, acName : string, openingBalance : float, initialoverdraft : float) _str_(self : PremiumAccount) : string + setovedraftLimit(self : PremiumAccount, newLimit : float) + getAvailableBalance(self : PremiumAccount) : float + printBalance(self : PremiumAccount) + closeAccount(self : PremiumAccount) : boolean

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 Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions