Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do not use any other libraries than specified..The program should be written in Python Do not use any other libraries than specified..The program should be

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Do not use any other libraries than specified..The program should be written in Python
Do not use any other libraries than specified..The program should be written in Python
You are to design an implement two classes in Python: BasicAccount and Premium Account 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): 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 + getAcNun(self : BasicAccount) : string + issueNewCard(self : BasicAccount) + closeAccount(self : BasicAccount) : boolean + PremtumAccount overdraft boolean overdraftLintt : float init self 3 Prentumaccount, acanestring, openingBalance i float, initialoverdraft : Float) stri (self Premium Account) : string setovedraftLimit(self : PremtunAccount) newLimit: float) getAvailableBalance(self : PrenturAccount) : float printBalance(self : PrentumAccount) closeAccount (self Premium Account boolean 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. leg: 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 Midtbad ATM . close Account(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). You must keep both classes in a single file: BankAccounts.py You may write some test code in the main body, but this must not run if your file is imported into another module

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

Lo6 Identify several management development methods.

Answered: 1 week ago