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 ?
1
Expert's answer
2012-10-02T07:39:07-0400
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 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."); & }
Comments
Leave a comment