|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectde.upb.swtpra05.group03.companycontrol.CompanyMainControl
The Main Class of the CompanyControl. This Class inhabits the public static void main Method.
| Field Summary | |
private Accounting |
accountObj
Reference on the account data control |
private CompanyControlClient |
client
Reference on CompanyControlClient |
private Control |
controlObj
Reference on the control panel included in the frame |
private Display |
displayObj
Reference on the display panel included in the frame |
private UserInterface |
frame
Reference on CompanyControlFrame |
float[] |
lastMarginValues
saves the last sent margin values TODO set private after finishing tests |
int |
lastRiskFactor
saves the last sent risk factor TODO set private after finishing tests |
boolean |
lastSelfAdopt
saves the last sent self adopt value TODO set private after finishing tests |
private Log |
logObj
Reference on the control panel in the frame |
java.util.Map |
orderList
This hashmap contains the current offered orders. |
private PluginLoader |
pluginloader
The PluginLoader |
int |
priceDifference
the difference of the price for a shuttle between a station with x and a station with x+1 shuttles. |
boolean |
priceDifferenceNotSet
helper for priceDifference TODO set private after finishing tests |
java.util.Map |
shuttleListCopy
copy of current shuttle ist. |
private int |
shuttleListSize
the current size of the shuttleList. |
java.util.Map |
shuttleStockCopy
copy of current shuttle stock. |
private int |
shuttleStockSize
the current size of the shuttleStock. |
private java.lang.String |
simTime
the current simulation time |
| Constructor Summary | |
(package private) |
CompanyMainControl()
The constructor is called from the main method (see below). |
| Method Summary | |
void |
addOrder(OrderInformation order)
This method is called by CompanyControlClient to add the given order to the orderList. |
void |
applyNewParams(float margin,
float minMargin,
float marginStep,
int riskFactor,
boolean selfAdopt)
This method sends a message to the shuttles concerning the changing of shuttle parameters. |
void |
buyShuttle(java.lang.String stationName,
int maxPrice)
This method is called from the GUI when the user presses the "Buy Shuttle" button. |
void |
calculatePriceDifference(java.util.Map shuttleStock)
This method is called by updateShuttleStock to calculate the value of priceDifference (see above). |
java.util.Map |
calculateRevenues(java.util.Map shuttleList)
This message is called by ControlMainControl itself after being informed about changes of the positions of the shuttles. |
int[] |
calculateTradeAdverts(java.util.Map shuttleStock)
This message is called by ControlMainControl itself after being informed about changes in the station's shuttle stock. |
void |
createAndShowGUI()
Create the GUI and show it. |
PluginLoader |
getPluginloader()
|
int |
getPriceToShuttle(int shuttleID)
This method is called by TradePanel when the user chooses a shuttle from the combo box. |
int |
getPriceToStation(java.lang.String stationName)
This method is called by TradePanel when user chose a station from the combo box. |
java.lang.String |
getSimTime()
accessor method for the current simulation time |
int |
getStationIDofOrder(int orderID)
This method is called by CompanyControlClient to get the start station ID of the order with the given ID |
private boolean |
lessProfitableThan(int champPrice,
int champTotalOrders,
int champCurrentOrders,
int challPrice,
int challTotalOrders,
int challCurrentOrders)
This method is called by calculateTradeAdverts to find out if the current most profitable price is worse than the one to test. |
static void |
main(java.lang.String[] args)
|
void |
removeOrder(int orderID)
This method is called by CompanyControlClient the remove the order with the given ID from the orderList. |
void |
sellShuttle(int shuttleID,
int minPrice)
this method is called from the GUI when the user presses the "Sell Shuttle" button. |
void |
sendParamsForNewShuttle()
This method is called by CompanyControlClient when a new shuttle was successfully bought. |
void |
setDisconnectState()
This method is called when Kernel is disconnected. |
void |
setReferencesForTesting(CompanyControlClient client,
Log logObj)
METHOD JUST FOR TESTING |
void |
setSimTime(int time)
This method is called by the CompanyControlClient to inform the MainControl about the current simulation time for logging. |
void |
setWaitState()
This method is called when the client tries to connect to the Kernel or has already connected, but no data for the different parts of the GUI have been sent. |
private void |
showNoParamsChangedDialog()
This method is called by applyNewParams (see below), when the user pressed the "Apply"-button without changing any parameters before. |
private boolean |
showStopShuttleDialog()
This method is called by the method sellShuttle (see below) when the user tries to sell a shuttle that is working at the moment. |
void |
updateAccountBalance(int balance,
int time)
This method is called from the CompanyControlClient, when a message concerning the company's money has arrived. |
void |
updateLogText(java.lang.String message)
This method is called by itself or by CompanyControlClient when new news exist that could be interesting for the company. |
void |
updateShuttleList(java.util.Map shuttleList)
This method is called by CompanyControlClient when the shuttle list or the positions of the shuttles have changed and the GUI's shuttle shuttle list table and the shuttle combo box have to be updated. |
void |
updateShuttleStock(java.util.Map shuttleStock)
This method is called by CompanyControlClient when the shuttle stock has changed and the GUI's stock list table and the stock combo box have to be updated. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private UserInterface frame
private CompanyControlClient client
private Control controlObj
private Display displayObj
private Log logObj
private Accounting accountObj
private java.lang.String simTime
private int shuttleListSize
public java.util.Map shuttleListCopy
private int shuttleStockSize
public java.util.Map shuttleStockCopy
public java.util.Map orderList
public int priceDifference
public boolean priceDifferenceNotSet
public int lastRiskFactor
public float[] lastMarginValues
public boolean lastSelfAdopt
private PluginLoader pluginloader
| Constructor Detail |
CompanyMainControl()
| Method Detail |
public void setReferencesForTesting(CompanyControlClient client,
Log logObj)
client - the client to setlogObj - the log object to test
TODO Delete aftre finishing testspublic void setWaitState()
public void setDisconnectState()
public void updateAccountBalance(int balance,
int time)
balance - the current company's account balancetime - the current simulation timepublic void setSimTime(int time)
time - current simulation timepublic java.lang.String getSimTime()
public void updateLogText(java.lang.String message)
message - news to be shown in the log textpublic void updateShuttleList(java.util.Map shuttleList)
shuttleList - includes information about the company's shuttlespublic int getPriceToShuttle(int shuttleID)
shuttleID - the shuttle to find the revenue of
public java.util.Map calculateRevenues(java.util.Map shuttleList)
shuttleList - includes information about the company's shuttles
public void updateShuttleStock(java.util.Map shuttleStock)
shuttleStock - includes information about the station's stockspublic int getPriceToStation(java.lang.String stationName)
stationName - the station to get the sale price of
public void calculatePriceDifference(java.util.Map shuttleStock)
shuttleStock - the current shuttle stock
private boolean lessProfitableThan(int champPrice,
int champTotalOrders,
int champCurrentOrders,
int challPrice,
int challTotalOrders,
int challCurrentOrders)
champPrice - the price of the current most profitable stationchampCurrentOrders - the current number of orders of the current most profitable
stationchampTotalOrders - the totally counted number of orders of the current most
profitable stationchallPrice - the price of the station to testchallCurrentOrders - the current number of orders of the station to testchallTotalOrders - the total number of orders of the station to test
public int[] calculateTradeAdverts(java.util.Map shuttleStock)
shuttleStock - includes information about the station's stocks
public void addOrder(OrderInformation order)
order - the order to addpublic void removeOrder(int orderID)
orderID - the order to removepublic int getStationIDofOrder(int orderID)
orderID - the order of which to get the start station ID
private void showNoParamsChangedDialog()
public void applyNewParams(float margin,
float minMargin,
float marginStep,
int riskFactor,
boolean selfAdopt)
margin - the size of the margin, itsminMargin - the minimum margingmarginStep - the size of the margin's stepsriskFactor - the parameter for the risc of the shuttlesselfAdopt - true when shuttles shall self-adopt, false elsepublic void sendParamsForNewShuttle()
public void buyShuttle(java.lang.String stationName,
int maxPrice)
stationName - the stationID where to buy a shuttlemaxPrice - the maximum price to buy a shuttle forprivate boolean showStopShuttleDialog()
public void sellShuttle(int shuttleID,
int minPrice)
shuttleID - the shuttleID of the shuttle to be soldminPrice - the minimum price to sell the shuttle for.public void createAndShowGUI()
public PluginLoader getPluginloader()
public static void main(java.lang.String[] args)
args -
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||