Please i have a challenge at hand can some-one help?

Create a class called BankAccount

Create a constructor that takes in an integer and assigns this to a `balance` property.
Create a method called `deposit` that takes in cash deposit amount and updates the balance accordingly.
Create a method called `withdraw` that takes in cash withdrawal amount and updates the balance accordingly. if amount is greater than balance return `"invalid transaction"`
Create a subclass MinimumBalanceAccount of the BankAccount class

this is the eg:

import unittest
class AccountBalanceTestCases(unittest.TestCase):
  def setUp(self):
    self.my_account = BankAccount(90)
    
  def test_balance(self):
    self.assertEqual(self.my_account.balance, 90, msg='Account Balance Invalid')
    
  def test_deposit(self):
    self.my_account.deposit(90)
    self.assertEqual(self.my_account.balance, 180, msg='Deposit method inaccurate')
    
  def test_withdraw(self):
    self.my_account.withdraw(40)
    self.assertEqual(self.my_account.balance, 50, msg='Withdraw method inaccurate')
    
  def test_invalid_operation(self):
    self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", msg='Invalid transaction')
  
  def test_sub_class(self):
    self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No true subclass of BankAccount')

Try to say what you want people to help with exactly :smile:
And one of the language specific categories might get you more responses than here.

We tend to shift all of these sorts of questions out of the exercise forums and over here.

edit: adding the language as a tag would be nice

2 Likes

I wasnt sure if the question was directly from an exercise, thats what I meant to say :slight_smile:

Oh, right. Iā€™m not 100% certain, but it doesnā€™t sound familiar. It could be a Pro project that I havenā€™t noticed yet.

This has come up a couple of times and I took it as a homework project, but it may be in the Pro tracks. Donā€™t know for sure.

1 Like

You might have it right there.

SO: http://stackoverflow.com/questions/34269517/create-a-class-called-bankaccount

https://groups.google.com/forum/#!topic/comp.lang.python/mmMjXf64X9M

etc.

Iā€™ve tagged it as homework now.

1 Like

its actually a home-work exercise that i avent come-across in my lifeā€¦u are right

thank you for your concern, i will check the link

ok please what is a ā€˜balanceā€™ properties, in OOP

pls what is a balance properties in OOP, according to the question

do you have a link where a matter like this is discussed:
Create a function manipulate_data that does the following
Accepts as the first parameter a string specifying the data structure to be used ā€œlistā€, ā€œsetā€ or ā€œdictionaryā€
Accepts as the second parameter the data to be manipulated based on the data structure specified e.g [1, 4, 9, 16, 25] for a list data structure
Based off the first parameter

return the reverse of a list or
add items `"UDOKA"`, `"UDO"` and `"NWOSU"` to the set and return the resulting set
return the keys of a dictionary.

I canā€™t help with your entire project, but the people who can help will be more interested in giving you advice if you show them the work that youā€™ve done already.

At least show them that you have started ā€¦

Reading what you just wrote about the assignment and picking out the base pieces:

Create a function manipulate_data ā€¦ that accepts two parameters ā€¦ and returns something

What would your code look like for just that much?

If you canā€™t do that, then instead of posting all of these instructions from your assignment, you should instead be asking for help on how to write a function. There is a Python course here at Codecademy that includes how to write functions.