You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.3 KiB
C#

/*
* C# Program to Demonstrate Transactions using Interface
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace sample
{
public interface ITransactions
{
void showTransaction();
double getamnt();
}
public class Transaction : ITransactions
{
private string Code;
private string date;
private double amnt;
public Transaction()
{
Code = " ";
date = " ";
amnt = 0.0;
}
public Transaction(string c, string d, double a)
{
Code = c;
date = d;
amnt = a;
}
public double getamnt()
{
return amnt;
}
public void showTransaction()
{
Console.WriteLine("Transaction: {0}", Code);
Console.WriteLine("Date: {0}", date);
Console.WriteLine("amnt: {0}", getamnt());
}
}
class example
{
static void Main(string[] args)
{
Transaction t1 = new Transaction("001", "24/06/2014", 87900.00);
Transaction t2 = new Transaction("002", "25/06/2014", 51900.00);
t1.showTransaction();
t2.showTransaction();
Console.ReadKey();
}
}
}
/*
Transaction: 001
Date: 24/06/2014
amnt: 87900
Transaction: 002
Date: 25/06/2014
amnt: 51900