Package model
Class GameModel
java.lang.Object
model.GameModel
- All Implemented Interfaces:
Serializable
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFacility
(Facility facility) Adds the facility to the city.void
Adds the buildable to the world map, reverse operation of removeFromMapvoid
Adds the zone to the city.double
Getting the revenue of the city.double
Getting the total expenses of the city.void
checkTemporaryDirectView
(Buildable buildable) If the new buildable blocks the forest view, reverses the effect of the forest.Gets everything on the map.Gets the statistics of the whole cityGets the current date in sense of the world of city.Buildable[][]
getMap()
Gets all zones which status is still under constructed.void
Initializes the settings inside game model.boolean
Checks if there is space for a certain buildableprintMap()
Gets the budget of the whole cityqueryZoneStatistics
(Coordinate coordinate) Gets the statistics of a specified zonevoid
regularUpdate
(int dayPass, ICallBack callBack) Regular updating of the world.void
removeBuildable
(Coordinate coordinate) removes a buildable completely from the city.boolean
Checks if the removal of road will result in lost of existing connectionvoid
updateTaxRate
(double newTaxRate) Updates city's tax rate
-
Constructor Details
-
GameModel
public GameModel(int rows, int cols)
-
-
Method Details
-
initialize
public void initialize()Initializes the settings inside game model. -
getMap
-
getAllBuildable
Gets everything on the map.- Returns:
- list of buildable.
-
getMasterRoads
-
getZoneBuildable
-
getCityRegistry
-
getFacilityBuildable
-
addZone
Adds the zone to the city. Updates its effect on satisfaction of other zones as well.- Parameters:
zone
- the zone reference to be added- Throws:
OperationException
-
checkTemporaryDirectView
If the new buildable blocks the forest view, reverses the effect of the forest.- Parameters:
buildable
- the new buildable to check.
-
addFacility
Adds the facility to the city.- Parameters:
facility
- the facility reference to be added- Throws:
OperationException
-
removeBuildable
removes a buildable completely from the city.- Parameters:
coordinate
- coordinate of the buildable to remove- Throws:
OperationException
- if removing empty slot.
-
roadIsEssentialForConnection
Checks if the removal of road will result in lost of existing connection- Parameters:
road
- th road to be checked- Returns:
- true if it will cause lost, otherwise false.
-
updateTaxRate
Updates city's tax rate- Parameters:
newTaxRate
- the new tax rate- Throws:
OperationException
-
getCityStatistics
Gets the statistics of the whole city- Returns:
- statistics
-
queryZoneStatistics
Gets the statistics of a specified zone- Parameters:
coordinate
- the coordinate of the zone for which statistics should be got- Returns:
- Zone
- Throws:
OperationException
- when no zone is on the coordinate.
-
queryCityBudget
Gets the budget of the whole city- Returns:
- budget
-
getCurrentDate
Gets the current date in sense of the world of city.- Returns:
- the date.
-
addToMap
Adds the buildable to the world map, reverse operation of removeFromMap- Parameters:
buildable
- buildable to be added.
-
printMap
- Returns:
- a string, whose prints out will be the map.
-
isPlotAvailable
Checks if there is space for a certain buildable- Parameters:
b
- the buildable to be checked- Returns:
- true if there is space, otherwise, false.
-
regularUpdate
Regular updating of the world.- Parameters:
dayPass
- the day passed since last updates.callBack
- a call back function, called after the updating, to synchronize the change to the view.
-
calculateSpend
public double calculateSpend()Getting the total expenses of the city.- Returns:
- the total pension and maintenance
-
calculateRevenue
public double calculateRevenue()Getting the revenue of the city.- Returns:
- the amount of tax collected
-
getUnderConstructions
Gets all zones which status is still under constructed.- Returns:
- the list
-