public Stock(string id, string company, StockSide side, int qty) { this.Id = id; this.Side = side; this.Company = company; this.Quantity = qty; this.RemQuantity = qty; this.Status = StockState.Open; }
private Stock ParseStock(string line) { string[] rows = line.Split(','); if (rows.Length != 4) { return(null); } if (!int.TryParse(rows[3], out int qty)) { throw new Exception("Invalid value for quantity"); } StockSide side = StockSide.Sell; if (rows[2].ToLower() == "buy") { side = StockSide.Buy; } return(new Stock(rows[0], rows[1], side, qty)); }