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

homework

#1

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')

#2

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.


#3

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


#4

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


#5

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.


#6

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.


#7

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

http://ubuntuforums.org/showthread.php?t=2307142

etc.

I've tagged it as homework now.


#8

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


#9

thank you for your concern, i will check the link


#10

ok please what is a 'balance' properties, in OOP


#11

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


#12

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.

#13

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.