/// <summary> /// Shares the processing. /// </summary> public void ShareProcessing() { while (true) { StockAccount stockDetails = new StockAccount(); Console.WriteLine("please enter the below acccording to your choice"); Console.WriteLine("0. for exit from the window"); Console.WriteLine("1. for Buy Share"); Console.WriteLine("2. for Sell share"); Console.WriteLine("3. for Display existing share"); Console.WriteLine("4. Display the symbol of Purchased shares"); string stringOption = Console.ReadLine(); if (Utility.CheckString(stringOption)) { Console.WriteLine("input not valid"); continue; } if (Utility.ContainsCharacter(stringOption)) { Console.WriteLine("character not allwoed"); continue; } int option = Convert.ToInt32(stringOption); switch (option) { case 0: Environment.Exit(0); break; case 1: InputData.TakeInputFromUser(option); break; case 2: InputData.TakeInputFromUser(option); break; case 3: stockDetails.PrintReport(); break; case 4: stockDetails.PrintSymbols(); break; default: return; } } }
/// <summary> /// Takes the input from user. /// </summary> /// <param name="choosedOption">The choosed option.</param> public static void TakeInputFromUser(int choosedOption) { StockAccount stockDetails = new StockAccount(); int numberOfshare = 0; int costOfShare = 0; string symbol = string.Empty; string dateTime = string.Empty; if (choosedOption == 1) { while (true) { Console.WriteLine("please enter the number of shares"); string numberOfShares = Console.ReadLine(); if (Utility.IsNumber(numberOfShares) == false) { Console.WriteLine("invalid input"); continue; } numberOfshare = Convert.ToInt32(numberOfShares); break; } while (true) { Console.WriteLine("please enter the of CostOfShare"); string costOfShare1 = Console.ReadLine(); if (Utility.IsNumber(costOfShare1) == false) { Console.WriteLine("invalid input"); continue; } costOfShare = Convert.ToInt32(costOfShare); break; } while (true) { Console.WriteLine("please enter the symbol"); string stringSymbol = Console.ReadLine(); if (Utility.CheckString(stringSymbol)) { Console.WriteLine("empty string not allwoed"); continue; } symbol = stringSymbol; break; } stockDetails.BuyShare(numberOfshare, costOfShare, symbol); } if (choosedOption == 2) { while (true) { Console.WriteLine("please enter the symbol for share"); string stringSymbol = Console.ReadLine(); if (Utility.IsNumber(stringSymbol) == true) { Console.WriteLine("number not allowed"); continue; } if (Utility.CheckString(stringSymbol)) { Console.WriteLine("empty string not allowed"); } symbol = stringSymbol; stockDetails.SellsOfShare(symbol); break; } } }