Question: Write a PHP class that implements a bank account for deposits and withdrawals. This class will have data members representing name and balance. It will

Write a PHP class that implements a bank account for deposits and withdrawals. This class will have data members representing name and balance. It will also have a constructor that takes a name parameter and sets the name data member accordingly. Create functions for getbalance and getname. Create a function for deposit that will check if deposit amount is positive and if so add it to the account. Create a function for withdraw that will check if the withdraw amount is positive and if the it is less than the account balance and if so withdraw it. Lastly create a __tostring method that will print out the account details when the object is used in an expression block.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!