Why have you declared them as static?
Don't call them bankList..., *list, while they are actually arrays. List is a different data structure.
Erdene Yadam wrote:I need help to make this code short.
Why such requirement? How about correctness of your simulation game? All good already? It isn't. Your program structure is wrong. Would you like to tell a bit more about project, maybe share instructions, so we could give some better advises rather than how to shorten the code. Question would have been liked more if it were "How to add more clarity to my program?"
thanks for a reply.
Instructions for this project.
You are to create a stock market simulation game, which has many of the characteristics of real electronic
commerce. The entities in the game are a bank, a stock exchange, and several companies and players.
Bank: The bank holds the money of one customer (one player or company). A customer can open a new
account, and deposit and withdraw money from the account. Once every 10 seconds during the game, all
money in an account accumulates interest. The interest for the customers with the highest and second
highest amount of money is 5%, while the interest for the other customers is 3%.
Company: A company has a name and can issue stock. Initially each company has 1000 shares of stock,
which starts at $30 a share. A company buys or sells shares to a player by accepting or rejecting the player's
Player: A player initially has $2000 in the bank, and buys and sells stock from companies or other players
by trading through the stock exchange. The goal of a player is to make money. A player buys or sells shares
from other players or companies by posting bids on the stock through stock exchange.
Stock Exchange: All trading of stocks must go through the centralized stock exchange. For each stock that
is being selling, the stock exchange posts the latest transaction of that stock if possible. The stock exchange
also displays the information of each bidder (the bidding price and name of the player/company). The stock
exchange stores the stock transaction information in a txt file.
Suppose we have three companies and five players in our game. When the players or companies want to
sell the stocks is random, the number of the stocks to be sold is also random. At any time point, we have at
most one type of stock that is being selling. For a stock, the number of bidders is random. One company or
player may accept or reject other players' or companies' bids. The bidding price of each player or company
could be random, you can also manually enter the price yourself if you want. After all bidders place the bid,
if the highest bidding price is no less than 0.9 * the price of the latest transaction of that stock, then the play
or company accepts the bid; otherwise, the player or company rejects the bid. If a stock is being selling for
the first time, whether the selling player or company accepts the highest bidding price is random (the
highest bidding price should not be zero). You should try to generate the corresponding random number
within the reasonable range. For example, we have three companies and five players, if one company or
player plan to sell the stocks, then the number of bidders should be within the range [0, 7]. Let your
program run some time (30 seconds for example) and see which player wins the game.
That might be a bit more interesting than we see usually. Will read it later tonight. Not sure how much you have accomplished that assignment, but if not much I'd suggest to draw a clear diagram, as it is quite a lot information to perceive in the head as a whole.
What classes along with relevant methods you have created and tested already?
There’s no place like 127.0.0.1. But I'll always remember this tiny ad: