C#C
C#3y ago
Juliandyce

❔ I cant find the mistake

.Amount gets unterlined
using System.Transactions;
using System.Collections.Generic;
using System;


namespace MyBank
{
    class Bank
    {
        static void Main(string[] args)
        {
            var account = new BankAccount("Julian", 10000);
            Console.WriteLine("Account {0} was createt for {1} with {2}.", account.Number, account.Owner, account.Balance);

        }
    }
}
namespace Classes
{
    public class Transaction
    {
        public decimal Amount { get; }
        public DateTime Date { get; }
        public string Notes { get; }

        public Transaction(decimal amount, DateTime date, string note)
        {
            Amount = amount;
            Date = date;
            Notes = note;
        }
    }
}
namespace MyBank
{
    public class BankAccount
    {

        public string Number
        {
            get;
        }
        public string Owner
        {
            get;
            set;
        }
        public decimal Balance
        {
            get
            {
                decimal balance = 0;
                foreach (var item in allTransactions) 
                {
                    balance = balance + item.Amount;
                }
                return balance;
            }
        }
        
        private static int accountNumberSeed = 0000000001;
        
        private List<Transaction> allTransactions = new List<Transaction>();

        public BankAccount(string name, decimal initialBalance)
        {
            this.Owner = name;           
            this.Number = accountNumberSeed.ToString();
            accountNumberSeed++;
        }

        public void MakeDeposit(decimal amount, DateTime date, string note)
        {
        }

        public void MakeWithdrawal(decimal amount, DateTime date, string note)
        {
        }

    }
}

https://www.youtube.com/watch?v=xLhm3bEG__c&t=222s
c# tutorial of .Net
YouTubedotnet
Learn more ➡️ https://learn.microsoft.com/users/dotnet/collections/yz26f8y64n7k07

Now our objects need data and behaviors. What can our objects DO and what do they HAVE? Let’s learn how to make members and methods with C# and .NET.

👩‍💻 Get the .NET Interactive Notebooks and follow along at home: https://aka.ms/csharp101notebooks

🏫 Free self-...
Was this page helpful?