107 296
Assignments Done
97.7%
Successfully Done
In March 2023

# Answer to Question #240047 in C# for Gayatri

Question #240047

Task 5: Implement only the Deposit method to increment the Balance. Keep the other two methods abstractin the class.

Task 6: Now let’s create concrete classes which are inherited from the BankAccount class.

Concrete Bank Account Classes having their own rules for Minimum Balance class ICICI // Inherit this from BankAccount

{

Withdraw() // Override this method

{

// If Balance – amount is >= 0 then only WithDraw is possible.

// Write the code to achieve the same.

}

Transfer() //Override this method

{

// If Balance – Withdraw is >= 1000 then only transfer can take place.

// Write the code to achieve the same.

}

}

class HSBC // Inherit this from BankAccount

{

Withdraw() //Override this method

{

// If Balance – amount is >= 5000 then only WithDraw is possible.

// Write the code to achieve the same.

}

Transfer() //Override this method

{

// If Balance – Withdraw is >= 5000 then only transfer can

take place.

// Write the code to achieve the same.

}

}

1
2021-09-22T08:30:49-0400
Task 5:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BankAccountLibrary
{
class ICICI: BankAccount // Inherit this from BankAccount
{
public ICICI(double amount)
: base(amount)
{

}
public override bool Withdraw(double amount)
{
// If Balance – amount is >= 0 then only WithDraw is possible.
// Write the code to achieve the same.
if (balance - amount >= 0){
balance -= amount;
Console.WriteLine("The amount has been withdrawed.");
return true;
}
return false;
}

public override bool Transfer(IBankAccount toAccount, double amount)
{
// If Balance – Withdraw is >= 1000 then only transfer can take place.

// Write the code to achieve the same.
if (balance - amount >= 1000)
{
return (this.Deposit(amount) && toAccount.Withdraw(amount));
}
return false;
}

}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BankAccountLibrary
{
class HSBC : BankAccount // Inherit this from BankAccount
{
public HSBC(double amount)
: base(amount)
{

}

public override bool Withdraw(double amount)
{
// If Balance – amount is >= 5000 then only WithDraw is possible.

// Write the code to achieve the same.

if (balance - amount >= 5000)
{
balance -= amount;
Console.WriteLine("The amount has been withdrawed.");
return true;
}
return false;
}

public override bool Transfer(IBankAccount toAccount, double amount)
{
// If Balance – Withdraw is >= 5000 then only transfer can take place.

// Write the code to achieve the same.
if (balance - amount >= 5000)
{
return (this.Deposit(amount) && toAccount.Withdraw(amount));
}
return false;
}

}
}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!