64 696
Assignments Done
99,4%
Successfully Done
In September 2018

Answer to Question #15673 in C# for Zulekha

Question #15673
Define an abstract class ‘Bank’ having abstract methods as‘CreateAccount’ ‘depositAmount’ and ‘withDrawAmount’.Add methoddefinitions for ‘CalculateInterest’ and ‘SetIntereset’ as Non-Overridable.Define two classes ‘BharatiBank’ and ‘RupeeBank’ to derivefrom bank class.In main ,method create objects of BharatiBank’ andRupeeBank’ to represent Bank type and call their respective methods.Can Bank type call the derived classes own methods that re not defined inbank ?
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{

abstract class Bank
{
& public abstract& void CreateAccount();
& public abstract void depositAmount();
& public abstract& void withDrawAmount();
& public abstract& void CalculateInterest();
& public abstract& void SetIntereset();
}
class BharatiBank : Bank
{
& public override void depositAmount()
& {
throw new Exception("The method or operation is not implemented.");
& }

& public override void withDrawAmount()
& {
throw new Exception("The method or operation is not implemented.");
& }

& public override void CalculateInterest()
& {
Console.WriteLine("Calculate Bharati bank");
& }

& public override void SetIntereset()
& {
Console.WriteLine("Set Bharati bank");
& }

& public override void CreateAccount()
& {
throw new Exception("The method or operation is not implemented.");
& }
}
class RuppeBank : Bank
{
& public override void depositAmount()
& {
throw new Exception("The method or operation is not implemented.");
& }

& public override void withDrawAmount()
& {
throw new Exception("The method or operation is not implemented.");
& }

& public override void CalculateInterest()
& {
Console.WriteLine("Calculate Ruppe bank");
& }

& public override void SetIntereset()
& {
Console.WriteLine("Set Ruppe bank");
& }

& public override void CreateAccount()
& {
throw new Exception("The method or operation is not implemented.");
& }
}




&



class Program
{
& static void Main(string[] args)
& {
RuppeBank RB = new RuppeBank();
BharatiBank BB = new BharatiBank();
RB.CalculateInterest();
BB.CalculateInterest();
RB.SetIntereset();
BB.SetIntereset();


& }
}
}

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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions