Chapter 4: Learning Just Enough C# and VB.NET: Intermediate Syntax

99

'Implement Checking logic CurrentBalance += amount

Console.Writeline("Added " & amount.ToString() &

"to Checking Account")

End Sub

Public Sub Debit(ByVal amount As Decimal) Implements IAccount.Debit

'Implement Checking logic CurrentBalance -= amount

Console.Writeline("Debited " + amount.ToString() +

"from Checking Account")

End Sub

Public Property CurrentBalance As Decimal Implements IAccount.

CurrentBalance

End Class

Listing 4-4 Saving class that implements IAccount interface

C#:

using System;

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

using System.Text;

namespace FirstProgram

{

class Saving : IAccount

{

public void Credit(decimal amount)

{

//implement savings logic CurrentBalance += amount; Console.Writeline("Added " + amount.ToString() +

"to Saving Account");

}

public void Debit(decimal amount)

{

//implement savings logic CurrentBalance -= amount; Console.Writeline("Debited " + amount.ToString() +

"from Saving Account");

}

Page 122
Image 122
Microsoft 9GD00001 manual Listing 4-4 Saving class that implements IAccount interface