Beispiel #1
0
void AI_city::set_all_prices()
{
  for (int i = RES_NULL + 1; i < RES_MAX; i++) {
    Resource res = Resource(i);
    Resource_datum* res_dat = Resource_data[res];
    if (!res_dat->meta) {
      set_price(res);
    }
  }
}
bool StockTransactions::sell(Stocks symbol, MMTransactions& mm, int shares, int shares_owned)
{
	if (shares > get_sharesOwned())
	{
		return false;
	}
	else
	{
		set_price(symbol.get_currentPrice() * shares);
		set_shares(get_sharesOwned() - shares);
		mm.deposit(get_price());
		m_transactionType = transactionType::SALE;
		return true;
	}
}
Beispiel #3
0
void PriceInfo::MergeFrom(const PriceInfo& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_price()) {
      set_price(from.price());
    }
    if (from.has_size()) {
      set_size(from.size());
    }
    if (from.has_side()) {
      set_side(from.side());
    }
  }
  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
bool StockTransactions::purchase(Stocks symbol, MMTransactions& mm, int shares)
{
	double cost = symbol.get_currentPrice() * shares;
	if (mm.withdraw(cost))
	{
		set_price(cost);
		set_shares(shares);
		set_symbol(symbol.get_symbol());
		m_transactionType = transactionType::PURCHASE;
		return true;
	}
	else
	{
		return false;
	}
}
Beispiel #5
0
int main(void) {
  set_weight(100);
  set_price(1.25);
  std::cout << "Weight: " << get_weight() << ", Price: " << get_price() << std::endl;
  return 0;
}