BigKahuna1971
Member
- Joined
- Jul 3, 2023
- Messages
- 7
- Programming Experience
- Beginner
Be greatful for a bit of help as to where iv'e gone wrong here.
And the next part.
Be great if anyone could help.
Thanks in advance.
C#:
using BankyStuffLibrary;
using System;
using Humanizer;
namespace MySuperBank
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(3501.ToWords());
var account = new Bank_Account("Shazza", 10000);
Console.WriteLine($"Account {account.Number} was created for {account.Owner} with {account.Balance}.");
account.MakeWithdrawal(200, DateTime.Now, "Egg Chair");
account.MakeWithdrawal(50, DateTime.Now, "Xbox Game");
account.MakeWithdrawal(5, DateTime.Now, "Coke");
account.MakeWithdrawal(120, DateTime.Now, "Pc Game");
account.MakeWithdrawal(7, DateTime.Now, "Bigmac");
account.MakeWithdrawal(50, DateTime.Now, "Haircut");
account.MakeWithdrawal(35, DateTime.Now, "Steak");
Console.WriteLine(account.GetAccountHistory());
////hey this is a comment
//// Test for a negative balance.
//try
{
account.MakeWithdrawal(7500, DateTime.Now, "Attempt to overdraw");
}
catch (InvalidOperationException e)
{
Console.WriteLine("Exception caught trying to overdraw");
Console.WriteLine(e.ToString());
}
// Test that the initial balances must be positive.
try
{
var invalidAccount = new Bank_Account("invalid", -55);
}
catch (ArgumentOutOfRangeException e)
{
Console.WriteLine("Exception caught creating account with negative balance");
Console.WriteLine(e.ToString());
}
account.MakeWithdrawal(50, DateTime.Now, "Xbox Game");
Console.WriteLine(account.Balance);
}
}
}
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Humanizer;
namespace BankyStuffLibrary
{
public class Transaction
{
public decimal Amount { get; }
public string AmountForHumans {
get; }
public DateTime Date => ((int)Amount.ToWords();
public string Notes { get; }
public Transaction(decimal amount, DateTime date, string note)
{
Amount = amount;
Date = date;
Notes = note;
}
}
}
Thanks in advance.
Last edited by a moderator: