當前位置: 首頁>>代碼示例>>C#>>正文


C# Account.Withdraw方法代碼示例

本文整理匯總了C#中Account.Withdraw方法的典型用法代碼示例。如果您正苦於以下問題:C# Account.Withdraw方法的具體用法?C# Account.Withdraw怎麽用?C# Account.Withdraw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Account的用法示例。


在下文中一共展示了Account.Withdraw方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        static void Main(string[] args)
        {
            var acc = new Account(Guid.NewGuid());

            acc.Deposit(new Amount(3100));
            acc.Withdraw(new Amount(100));
            acc.Withdraw(new Amount(10000));

            foreach (var @event in acc.RecordedEvents())
                Console.WriteLine(@event);

            Console.ReadLine();

            var sw = new Stopwatch();

            sw.Start();

            var accountId = Guid.Parse("44b9da68-8415-4adc-b99f-2631f1115f9e");

            var account = new Account(accountId);

            for (var i = 0; i < 500; i++)
            {
                account.Withdraw(new Amount(i * 1000));
                account.Deposit(new Amount(i * 1000 * 2));
            }

            var eventStore = new FileEventStore();
            eventStore.Create(accountId, account.RecordedEvents());

            sw.Stop();

            Console.WriteLine(string.Format("Appended {0} events to stream in {1}.", account.RecordedEvents().Count(), sw.Elapsed.TotalSeconds));

            sw.Restart();

            var stream = eventStore.GetStream(accountId);

            new ProjectionToConsole().Handle(stream);

            sw.Stop();

            Console.WriteLine(string.Format("Read {0} events from stream in {1}.", stream.Count(), sw.Elapsed.TotalSeconds));

            sw.Reset();

            var restoredAccount = new Account(accountId);
            restoredAccount.Initialize(stream);

            sw.Stop();

            Console.WriteLine(string.Format("Replayed {0} events from stream in {1}.", stream.Count(), sw.Elapsed.TotalSeconds));
            Console.ReadLine();
        }
開發者ID:JefClaes,項目名稱:naive-eventsourcing,代碼行數:54,代碼來源:Program.cs

示例2: Main

        public static void Main()
        {
            var account = new Account("Jim Johnson");

            account.Deposit(500.0);
            account.Deposit(300.0);
            account.Deposit(550.0);
            account.PayInterest();
            account.Withdraw(1000.00);
            account.Withdraw(1100.00);
        }
開發者ID:Alex223124,項目名稱:High-Quality-Code,代碼行數:11,代碼來源:Program.cs

示例3: TestWithdrawNegative

	public void TestWithdrawNegative()
	{
		Account acc = new Account();
		acc.Withdraw(-3.14F);
		float balance = acc.Balance;
		Assert.AreEqual(balance, 1000F);
	}
開發者ID:Alex223124,項目名稱:High-Quality-Code,代碼行數:7,代碼來源:TestAccount.cs

示例4: TestWithdraw

	public void TestWithdraw()
	{
		Account acc = new Account();
		acc.Withdraw(138.56F);
		float balance = acc.Balance;
		Assert.AreEqual(balance, -138.56F);
	}
開發者ID:Alex223124,項目名稱:High-Quality-Code,代碼行數:7,代碼來源:TestAccount.cs

示例5: TestWithdrawNegative

 public void TestWithdrawNegative()
 {
     var acc = new Account();
     acc.Withdraw(-3.14M);
     var balance = acc.Balance;
     Assert.AreEqual(balance, 3.14M);
 }
開發者ID:EBojilova,項目名稱:CSharpHQC,代碼行數:7,代碼來源:AccountTest.cs

示例6: TestWithdraw

 public void TestWithdraw()
 {
     var acc = new Account();
     acc.Withdraw(138.56M);
     var balance = acc.Balance;
     Assert.AreEqual(balance, -138.56M);
 }
開發者ID:EBojilova,項目名稱:CSharpHQC,代碼行數:7,代碼來源:AccountTest.cs

示例7: TransferFunds

 public static void TransferFunds(Account sourceAccount,
                                  Account destinationAccount,
                                  float amount)
 {
     sourceAccount.Withdraw(amount);
     destinationAccount.Deposit(amount);
 }
開發者ID:paulrayner,項目名稱:console_app,代碼行數:7,代碼來源:MoneyMover.cs

示例8: Withdraw_NonEmptyAccount_ShouldPass

        public void Withdraw_NonEmptyAccount_ShouldPass()
        {
            var account = new Account();
            account.Deposit(3000.0);
            account.Withdraw(2000.0);

            Assert.AreEqual(1000.0, account.Balance);
        }
開發者ID:AngataHristov,項目名稱:High-Quality-Code,代碼行數:8,代碼來源:AccountTests.cs

示例9: TestDepositWithdrawTransferFunds

    public void TestDepositWithdrawTransferFunds()
    {
        var source = new Account();
        source.Deposit(200.00F);
        source.Withdraw(100.00F);

        var dest = new Account();
        dest.Deposit(150.00F);
        dest.Withdraw(50.00F);

        source.TransferFunds(dest, 100.00F);
        Assert.AreEqual(0.00F, source.Balance);
        Assert.AreEqual(200.00F, dest.Balance);
    }
開發者ID:EBojilova,項目名稱:CSharpHQC,代碼行數:14,代碼來源:TestAccount.cs

示例10: PrintAllClientStatements

        public void PrintAllClientStatements()
        {
            var account = new Account(transactionRepository, statementPrinter);

            account.Deposit(1000);
            account.Withdraw(100);
            account.Deposit(500);

            account.PrintStatement();

            Received.InOrder(() =>
            {
                console.Received().WriteLine("DATE       | AMOUNT  | BALANCE");
                console.Received().WriteLine("10/11/2015 | 500.00 | 1400.00");
                console.Received().WriteLine("02/11/2015 | -100.00 | 900.00");
                console.Received().WriteLine("01/11/2015 | 1000.00 | 1000.00");
            });
        }
開發者ID:robi-y,項目名稱:BankAccountKata,代碼行數:18,代碼來源:PrintStatementFeature.cs

示例11: TestWithdrawZero

	public void TestWithdrawZero()
	{
		Account acc = new Account();
		acc.Withdraw(0);
	}
開發者ID:Alex223124,項目名稱:High-Quality-Code,代碼行數:5,代碼來源:TestAccount.cs

示例12: Main

  public static void Main( string[] args )
  {
    // Open a new account
    Account account = new Account( "Patty La Belle" );

    // Apply financial transactions
    account.Deposit( 500.0 );
    account.Deposit( 300.0 );
    account.Deposit( 550.0 );
    account.PayInterest();
    account.Withdraw( 2000.00 );
    account.Withdraw( 1100.00 );
    
  }
開發者ID:tian1ll1,項目名稱:WPF_Examples,代碼行數:14,代碼來源:State_RealWorld.cs

示例13: Main

        static void Main(string[] args)
        {
            //open a new account
            Account account = new Account("Joe Bloggs");

            //Apply Financial transactions
            account.Deposit(500.0);
            account.Deposit(300.0);
            account.Deposit(550.0);
            account.PayInterest();
            account.Withdraw(2000.00);
            account.Withdraw(1100.00);

            //wait for user input
            Console.ReadKey(true);
        }
開發者ID:Paulmcl78,項目名稱:PatternPractice,代碼行數:16,代碼來源:Program.cs


注:本文中的Account.Withdraw方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。