Hi,
While reading code on implementation part, you can find the following:
public class StockExchange {
private static StockExchange stockExchangeInstance = null;
// private constructor to restrict for singleton
private StockExchange() { }
// static method to get the singleton instance of StockExchange
public static StockExchange getInstance()
{
if(stockExchangeInstance == null) {
stockExchangeInstance = new StockExchange();
}
return stockExchangeInstance;
}
public static boolean placeOrder(Order order) {
boolean returnStatus = getInstance().submitOrder(Order);
return returnStatus;
}
}
My question would be where to implement getInstance().submitOrder()
? Is it private method of the same singleton class? If yes, then why we would have two methods with names placeOrder()
and submitOrder()
?
Thanks.