repl.it
@kironroy/

interfaces

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
  • notes.txt
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;

namespace Interface2
{

    public interface ITransactions
    {
        // interface members 
        void showTransactions();
        double getAmount();
    } // Interface Transaction END

    public class Transaction : ITransactions
    {
        // class members
        private string _code;
        private string _date;
        private double _amount;

        public Transaction()
        {
            _code = " ";
            _date = " ";
            _amount = 0.0;
        }

        public Transaction(string code, string date, double amount)
        {
            _code = code;
            _date = date;
            _amount = amount;
            
        }

        public double getAmount()
        {
            return _amount;
        }

        public void showTransaction()
        {
            Console.WriteLine($"Transaction: {_code}");
            Console.WriteLine($"Date: {_date}");
            Console.WriteLine($"Amount: {getAmount()}");
        }

        public void showTransactions()
        {
            throw new NotImplementedException();
        }
    } // Class Transaction END

    class TransactionTester
    {
        static void Main(string[] args)
        {
            var trans1 = new Transaction("001", "8/10/2018", 7845.00);
            var trans2 = new Transaction("002", "10/10/2018", 7945.00);

            trans1.showTransaction();
            trans2.showTransaction();
        }
    }



} // namespace END