Ejemplo n.º 1
0
 public static DateProvider GetInstance()
 {
     if (instance == null)
     {
         instance = new DateProvider();
     }
     return(instance);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Operación que permite realizar un retiro en la cuenta.
 /// </summary>
 /// <param name="pAmount">Monto del retiro.</param>
 /// <returns>Monto retirado.</returns>
 /// <exception cref="System.ArgumentException">amount must be greater than zero</exception>
 /// <exception cref="System.ArgumentException">insufficient funds</exception>
 public double Withdraw(double pAmount)
 {
     if (pAmount <= 0)
     {
         throw new ArgumentException("amount must be greater than zero");
     }
     else if (pAmount > Balance)
     {
         throw new ArgumentException("insufficient funds");
     }
     else
     {
         _transactionsList.Add(new Transaction(-pAmount));
         Balance     -= pAmount;
         LastWithdraw = DateProvider.GetInstance().Now();
         return(pAmount);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Inicializa una nueva instancia de la clase <see cref="Account"/> sin transacciones.
        /// </summary>
        /// <param name="pAccountType">Tipo de cuenta.</param>
        public Account(AccountType pAccountType)
        {
            switch (pAccountType)
            {
            case AccountType.Checking:
                Number = ++_idAccCheking;
                break;

            case AccountType.Savings:
                Number = ++_idAccSaving;
                break;

            case AccountType.MaxiSavings:
                Number = ++_idAccMaxiSaving;
                break;
            }

            Type              = pAccountType;
            Balance           = 0;
            DateCreate        = DateProvider.GetInstance().Now();
            _transactionsList = new List <Transaction>();
            LastWithdraw      = null;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Inicializa una nueva instancia de la clase <see cref="Transaction"/>.
 /// </summary>
 /// <param name="pAmount">Monto de la transacción.</param>
 public Transaction(double pAmount)
 {
     Amount = pAmount;
     Number = ++_idTransaction;
     Date   = DateProvider.GetInstance().Now();
 }
Ejemplo n.º 5
0
 public Transaction(double amount)
 {
     this.amount          = amount;
     this.transactionDate = DateProvider.GetInstance().Now();
 }