public Table(Deck deck) : this() { Stock1.AddRange(deck.DeckCards.GetRange(24, 1)); Stock1.Last().IsReversed = true; Stock2.AddRange(deck.DeckCards.GetRange(25, 2)); Stock2.Last().IsReversed = true; Stock3.AddRange(deck.DeckCards.GetRange(27, 3)); Stock3.Last().IsReversed = true; Stock4.AddRange(deck.DeckCards.GetRange(30, 4)); Stock4.Last().IsReversed = true; Stock5.AddRange(deck.DeckCards.GetRange(34, 5)); Stock5.Last().IsReversed = true; Stock6.AddRange(deck.DeckCards.GetRange(39, 6)); Stock6.Last().IsReversed = true; Stock7.AddRange(deck.DeckCards.GetRange(45, 7)); Stock7.Last().IsReversed = true; ReserveStock.AddRange(deck.DeckCards.GetRange(0, 24)); ReserveStock.Last().IsReversed = true; }
public Fund() { gu1 = new Stock1(); gu2 = new Stock2(); gu3 = new Stock3(); nd1 = new NationDebt1(); rt1 = new Realty1(); }
private static void PerformSellStock1(Stock1 stock) // sell stock function { int sellStockAmount; Console.WriteLine("Enter the stock amount need to sell"); sellStockAmount = Convert.ToInt32(Console.ReadLine()); if (stock.RemoveStock1(sellStockAmount)) { Console.WriteLine(" " + sellStockAmount + " stock removed successfully"); } else { Console.WriteLine("stock not removed successfully"); } }
private static void PerformBuyStock1(Stock1 stock) // buy stock function { int addStockAmount; Console.WriteLine("Enter amount of new stock"); addStockAmount = Convert.ToInt32(Console.ReadLine()); if (stock.AddStock1(addStockAmount)) // performing the boolian function to check whether the stock added is successful or not { Console.WriteLine(" " + addStockAmount + " New stock added"); } else { Console.WriteLine(" Stock cant be negative, Hence it is failed"); } }
public string get_stock1(string stock_num) { string url = string.Format("https://tw.stock.yahoo.com/q/q?s={0}", stock_num); string result = get_url(url, 1); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(result); var title = htmlDoc.DocumentNode.SelectNodes(@"//td[@align='center']"); //Title string title2 = title[0].InnerText; string price = title[2].InnerText; Stock1 stock1 = new Stock1(); stock1.stock_name = title2; stock1.stock_price = price; string result2 = JsonConvert.SerializeObject(stock1); return(result2); } //Yahoo Stock
public static void Main() { MenuOption userSelection; Stock1 test = new Stock1(" Available stock item", 100); // Creating stock object for the item and setting the initial stock item to 100 do { userSelection = ReadUserOption(); // perform the switch operations to perform the special operations switch (userSelection) { case MenuOption.BuyStock: Console.WriteLine(" "); PerformBuyStock1(test); // perform the buy stock Console.WriteLine(" "); break; case MenuOption.SellStock: Console.WriteLine(" "); PerformSellStock1(test); // perform the sell stock Console.WriteLine(" "); break; case MenuOption.QueryStock: Console.WriteLine(" "); PerformQueryStock1(test); // It display the available stock Console.WriteLine(" "); break; case MenuOption.Quit: Console.WriteLine(" "); Console.WriteLine("Quit ... "); Console.WriteLine(" "); break; } }while (userSelection != MenuOption.Quit); Console.WriteLine(userSelection); }
static void Main(string[] args) { // 客服端买股票 股民 Stock1 s1 = new Stock1(10); Stock2 s2 = new Stock2(20); Stock3 s3 = new Stock3(40); // 模拟 买 基金 Fund sFund = new Fund(); sFund.Buy(); sFund.Sell(); //不需要 对 股票进行炒作, 只需要 炒作 基金, 由基金 去操作股票; //中介者 模式 Facade facade = new Facade(); // 外观模式 会把所有子系统 集合在一起, 然后 封装它们的方法, 外部 只要调用就好了。 facade.MethodA(); facade.MethodB(); }
private static void PerformQueryStock1(Stock1 stock) { stock.PrintSummary(); // print the available stock }