0

Don't know if you will see me a lot today.
Must say you already did a nice job in translating this from C++ to C#.
I tweaked your code a bit and added some comments.
It even compiles and starts up now.
This is how my console screen looks after typing 1 and 2;
AccountConsole.png
I also include the modified files in a zip so you can work further on them.
Success!
Any questions, please ask.

0

//thanks,have a question ,are the parameters list in the rest of the functions ,like withdraw,logement (in switch)should be empty too?

0

A bit confused here:
public static void Lodgement()//List<Account> list)

   //    A bit confused here:
        public static void Lodgement()//List<Account> list)
        {

            Console.WriteLine("Process Logement");
            Console.WriteLine("Enter account name");
            string name = Console.ReadLine();
            Console.WriteLine("Enter logement amount");
          int logementAmount = Console.ReadLine();//??

          list.credit(logementAmount); //???

           //Display ???




       }

Edited by PulsarScript

0

This is what I first would come up with:

public static void Lodgement()//List<Account> list)
        {
            try
            {
                Console.WriteLine("Process Lodgement");
                Console.WriteLine();
                Console.Write("Enter account name: ");
                string name = Console.ReadLine();
                Console.Write("Enter lodgement amount: ");
                double lodgementAmount = Convert.ToDouble(Console.ReadLine());
                int accountIndex = list.FindIndex(x => x.Name == name);
                list[accountIndex].Credit(lodgementAmount);
                Console.WriteLine("New balance details:");
                list[accountIndex].Display();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e.Message);
            }
        }

Hope this very much explains itself, except perhaps the lambda expression in FindIndex. As this is a financial application, you could perhaps switch to a decimal type instead of a double type for the amounts.

0

Thanks,managed to do wihdrawal method too,very similar.Question,values i change exists only,while i run program and once exit and restart,values appears by default harcoded unchanged? Is it supposed to be like this?

0

Don't know exactlywhat you mean, but values that are typed in are lost when the program finishes, unless you implement some sort of filing.

0

How different the dynamic cast in c#,try to figure out for interestRate method. And is it possible to change exception to custom message,like account name does not exists for logement method?Thanks

0

C# has only one cast. If you want to cast a variable to a type you do
(Atype)Avariable
In the catch part you can write as many WriteLines as you like.

0

Thank you.I manged to finish it.
From your file i can see you are interested in maths too.Do you do any algorithms to find prime for instance or cryptology in c#?

0

Click on my avatar and then on the code snippets link. Several snippets in the list are related to math. Or go directly clicking my snips

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.