本文整理汇总了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();
}
示例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);
}
示例3: TestWithdrawNegative
public void TestWithdrawNegative()
{
Account acc = new Account();
acc.Withdraw(-3.14F);
float balance = acc.Balance;
Assert.AreEqual(balance, 1000F);
}
示例4: TestWithdraw
public void TestWithdraw()
{
Account acc = new Account();
acc.Withdraw(138.56F);
float balance = acc.Balance;
Assert.AreEqual(balance, -138.56F);
}
示例5: TestWithdrawNegative
public void TestWithdrawNegative()
{
var acc = new Account();
acc.Withdraw(-3.14M);
var balance = acc.Balance;
Assert.AreEqual(balance, 3.14M);
}
示例6: TestWithdraw
public void TestWithdraw()
{
var acc = new Account();
acc.Withdraw(138.56M);
var balance = acc.Balance;
Assert.AreEqual(balance, -138.56M);
}
示例7: TransferFunds
public static void TransferFunds(Account sourceAccount,
Account destinationAccount,
float amount)
{
sourceAccount.Withdraw(amount);
destinationAccount.Deposit(amount);
}
示例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);
}
示例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);
}
示例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");
});
}
示例11: TestWithdrawZero
public void TestWithdrawZero()
{
Account acc = new Account();
acc.Withdraw(0);
}
示例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 );
}
示例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);
}