input
stringlengths
10
828
output
stringlengths
5
107
private void show countries jta mesgs append n jta mesgs append n jta mesgs append list of the countries jta mesgs append n jta mesgs append jta mesgs append n jta mesgs append l countries to string
method that shows the countries in the system
public race get race return this race
method that return the native race of the planet
private void show players jta mesgs append n jta mesgs append n jta mesgs append list of the players jta mesgs append n jta mesgs append jta mesgs append n jta mesgs append l players to string
method that shows the players in the system
private void show planets jta mesgs append n jta mesgs append n jta mesgs append list of the planets jta mesgs append n jta mesgs append jta mesgs append n jta mesgs append l planets to string
method that shows the planets in the system
private string list vehicles vehicle vehicle string vehicles list vehicles list n iterator vehicle it for it this l vehicles iterator it has next vehicle it next vehicles list vehicle to string return vehicles list
method that return the list of all vehicles in the system
public string get req code int num req code switch num req code case 1 return this req1 code case 2 return this req2 code case 3 return this req3 code default return null
method that return the code of the technology required
public int get req quantity int num req code switch num req code case 1 return this req1 quantity case 2 return this req2 quantity case 3 return this req3 quantity default return 0
method that return the quantity of the code of the technology required
private void write commands file open the flow to write try write files build writer data commands test catch exception e system err println e get message system exit 1 write information into the file write files file out println create commands countries write files file out println create commands players write files file out println create commands players details write files file out println create commands planets close the flow to write try write files close streams catch exception e system err println e get message system exit 1 end of write commands file
button that writes the file commands into the hdd
public int get total points int total points 0 for int i 0 i planet dimension x i for int j 0 j planet dimension y j points for buildings if array buildings i j null total points array buildings i j get points points for vehicles if array vehicles i j null total points array vehicles i j get points return total points
method that calculate the total points for the planet for the player
private string list planets planet planet string planets list planets list n iterator planet it for it this l planets iterator it has next planet it next planets list planet to string return planets list
method that return the list of all planets in the system
public string get tech got return this tech got
method that return the code of the technology got with this technology researched
private string buffer create commands countries string buffer commands new string buffer n adding countries to the system n n countries n n parameters name abbreviation language flag n for int i 0 i l countries size i commands append add country l countries get i to command n return commands end of create commands countries
method that creates the strings about countries to write into the hdd
public int get total extraction string id vehicle int total extraction 0 for int i 0 i planet dimension x i for int j 0 j planet dimension y j if array vehicles i j null if array vehicles i j get id equals id vehicle total extraction array vehicles i j get production index return total extraction
method that calculate the total extraction for the planet
private string buffer create commands planets string buffer commands new string buffer n adding planets to the system n n planets n n parameters internal code filename assoc planet name description dimension x dimension y position x position y num metal avail num mineral avail num water avail num food avail num energy avail num credits avail taxes temperature radiation owner player n for int i 0 i l planets size i commands append add planet l planets get i to command n return commands end of create commands planets
method that creates the strings about planets to write into the hdd
private string list players player player string players list players list n iterator player it for it this l players iterator it has next player it next players list player to string return players list
method that return the list of all players in the system
public string get researchable yn return this researchable yn
method that return if this technology researchable by the user
private string buffer create commands players string buffer commands new string buffer n adding players to the system n n players n n parameters id player tech level researching now n for int i 0 i l players size i commands append add player l players get i to command n return commands end of create commands players
method that creates the strings about players to write into the hdd
private string buffer create commands players details string buffer commands new string buffer n adding personal details of the players in the system n n personal details n n parameters id player nickname password question remember pwd answer remember pwd real name language email address phone number town country avatar num games played num games won date last game played num turns played n for int i 0 i l players size i commands append add personal details l players get i to command details n return commands end of create commands players
method that creates the strings about players details to write into the hdd
private string list technologies technology tech string technologies list technologies list n iterator technology it for it this l technologies iterator it has next tech it next technologies list tech to string return technologies list
method that return the list of all technologies in the system
public void set race race p race this race p race
method that writes the name of the native race into the attribute race
public void set description string descri this description descri
method that write the description of the technology
public void add element planet element p element int pos x int pos y array elements pos x pos y p element
method that add an element into the array of the elements
public int get id player from return this id player from
method that return the id player from
public int get date sent return this date sent
method that return the date sent
public int get time sent return this time sent
method that return the time sent
private string list game string game data game data n game data game to string return game data
method that return the main data of the current game in the system
public void set req1 code string code this req1 code code
method that write the code of the technology 1 required to investigate
public boolean get read return this read
method that return the flag for read or unread
public void add vehicle vehicle p vehicle int pos x int pos y array vehicles pos x pos y p vehicle
method that add a vehicle into the array of the vehicles
public void set req1 quantity int quantity this req1 quantity quantity
method that write the quantity required of the technology 1 required to investigate
public void set req2 code string code this req2 code code
method that write the code of the technology 2 required to investigate
private boolean check cofexists string file name cof throws server exception try suppress warnings unused buffered reader in to check cof temp to check if cofs exists file f new file file name cof in to check cof new buffered reader new input stream reader new file input stream f iso 8859 1 return true catch ioexception e throw new server exception server exception cof not exists
method that check if the cof especified by param exists
public void add building building p building int pos x int pos y array buildings pos x pos y p building
method that add a building into the array of the buldings
public void set req2 quantity int quantity this req2 quantity quantity
method that write the quantity required of the technology 2 required to investigate
public void set req3 code string code this req3 code code
method that write the code of the technology 3 required to investigate
public void set req3 quantity int quantity this req3 quantity quantity
method that write the quantity required of the technology 3 required to investigate
public void set tech got string tech this tech got tech
method that write the code of the technology got with this technology researched
public void sub turns remained int turns this turns remained this turns remained turns
method add substract the number of turns remained to get this technology
public boolean check position free int pos x int pos y if array elements pos x pos y null array vehicles pos x pos y null return true else return false
method that checks if the position indicated is free
public void set researchable yn string is yn this researchable yn is yn
method that writes if this technology researchable by the user
public void set status string stat this status stat
method that changes the status of this technology
public list check buildings expiration int current turn int id player l buildings expired clear for int i 0 i planet dimension x i for int j 0 j planet dimension y j if array buildings i j null if array buildings i j check expiration current turn id player building expired l buildings expired add array buildings i j get id return l buildings expired
method that check the expirations of the buildings in the planet
public void set current turn int turn this current turn turn
method that sets the current turn
private void draw map to file string msg this out server println msg this out server close need to write every line
method that draw the map of the planet a file on the hd
public string get status description string status string status description stringnotdefined if status n status description not playing just created if status p status description playing if status f status description finished return status description
method that returns the description of the status code
private vehicle search vehicle string id vehicle for int i 0 i common variables l vehicles size i if vehicle common variables l vehicles get i get id compare to id vehicle 0 return vehicle common variables l vehicles get i return null
method that returns a vehicle from his id
public void write status file open the flow to write try write files build writer data this id game status false catch exception e system err println e get message system exit 1 write information into the file write files file out println this id game this description this status this date start this date end this current turn n write files file out close close the flow to write
creates a character string and writes it into the file gnnnn
public int read status file try string file name data this id game status read files build reader file name try string current line read files file in read line if current line null current line equals string st current line split if st length 6 throw new server exception server exception wrong command return integer parse int st 5 catch ioexception ex ex print stack trace catch server exception ex ex print stack trace return 1
read the information on gnnnn
private extractor search vehicle extractor string id vehicle for int i 0 i common variables l vehicles extractor size i if extractor common variables l vehicles extractor get i get id compare to id vehicle 0 return extractor common variables l vehicles extractor get i return null
method that returns a vehicle extractor from his id
public void set id int id this id player id
method that writes the id player
private technology search technology string code tech list technology l techs for int i 0 i l techs size i if technology l techs get i get code compare to code tech 0 return technology l techs get i return null
method that returns a technology in the game from his id
private int search country string name country for int i 0 i common variables l countries size i if common variables l countries get i get name equals name country return i return 1
method that returns a country from his name
private building search building string id building for int i 0 i common variables l buildings size i if building common variables l buildings get i get id compare to id building 0 return building common variables l buildings get i return null
method that returns a building from his id
private planet search planet int id planet for int i 0 i common variables l planets size i if planet common variables l planets get i get id id planet return planet common variables l planets get i return null
method that returns a planet from his id
private int search planet int id planet for int i 0 i common variables l planets size i if common variables l planets get i get id id planet return i return 1
method that returns a planet from his id
private player search player int id player for int i 0 i common variables l players size i if player common variables l players get i get id id player return player common variables l players get i return null
method that returns a player from his id
private int search player tech level int id player for int i 0 i common variables l players size i if player common variables l players get i get id id player return player common variables l players get i get tech level return 1
method that returns the technology level of a player from his id
private game search game string id game for int i 0 i common variables l games size i if common variables l games get i get id game id game return common variables l games get i return null
method that returns a game from his id
private string order repair string execute result null todo return execute result
method that process a repair order in the cof
private string list buildings building building string buildings list buildings list n iterator building it for it common variables l buildings iterator it has next building it next buildings list building to string return buildings list
method that return the list of all buildings in the system
private string list vehicles vehicle vehicle string vehicles list vehicles list n iterator vehicle it for it common variables l vehicles iterator it has next vehicle it next vehicles list vehicle to string return vehicles list
method that return the list of all vehicles in the system
private string list planets planet planet string planets list planets list n iterator planet it for it common variables l planets iterator it has next planet it next planets list planet to string return planets list
method that return the list of all planets in the system
private string list players player player string players list players list n iterator player it for it common variables l players iterator it has next player it next players list player to string return players list
method that return the list of all players in the system
private string list technologies technology tech string technologies list technologies list n iterator technology it for it common variables l technologies iterator it has next tech it next technologies list tech to string return technologies list
method that return the list of all technologies in the system
private void write file countries open the flow to write try write files build writer data zcountries false catch exception e system err println e get message system exit 1 write information into the file write files file out println create file countries close the flow to write try write files close streams catch exception e system err println e get message system exit 1 end of write file countries
method that writes the data into the hdd
private string buffer create file countries string buffer commands new string buffer n countries n n parameters name abbreviation language flag file n for int i 0 i common variables l countries size i commands append common variables l countries get i to command n return commands end of create commands countries
method that creates the strings about countries to write into the hdd
public void load data last turn string id game int id player int id planet game game search game id game load buildings game read buildings on last turn id player id planet load vehicles vehicles extractors transports game read vehicles on last turn id player id planet load technologies game read technologies on last turn id player id planet load resources load characters load map end of load data to execute turn
method that load the data from the status of the last turn
public int get creation turn return this creation turn
method that return the number of the turn in which was created
private boolean check main building created if common variables l player buildings null if common variables l player buildings size 0 if common variables l player buildings get 0 get id equals common constants main building return true else return false else return false else return false
check if the player have the main building government office
private boolean check exists cofs string file in null file to read orders player current player null boolean exists cofs false for int i 0 i common variables l players size i current player common variables l players get i if current player get id 0 file in data player current player get id cof current player get id this num turn exists cofs general functions check file exists file in if exists cofs break go out from the for return exists cofs
check that the cofs of all players are received
private void write file players open the flow to write try write files build writer data zplayers false catch exception e system err println e get message system exit 1 write information into the file write files file out println create file players close the flow to write try write files close streams catch exception e system err println e get message system exit 1 end of write file players
method that writes the data into the hdd
public int get extraction index return this extraction index
method that return the extraction index
private string buffer create file players string buffer commands new string buffer n players n n parameters id player nickname password question remember pwd answer remember pwd real name language email phone number town country avatar num games played num games won date last game played num turns played last game tech level researching now n for int i 0 i common variables l players size i commands append common variables l players get i to command n return commands end of create commands players
method that creates the strings about players to write into the hdd
private void calc messages int num msgs 0 int num msgs unread 0 for int i 0 i common variables l players msgs size i check if the message is sent to this player if integer parse int jtf player id get text common variables l players msgs get i get id player to num msgs if common variables l players msgs get i get read num msgs unread jtf msgs received set text integer to string num msgs jtf msgs unread set text integer to string num msgs unread
method that calculates how many messages has received the player
public void set position x int pos this position x pos
method that sets the position x of the vehicle
private void calculate buildings constructions for int i 0 i common variables l player buildings size i int end turn common variables l player buildings get i get creation turn common variables l player buildings get i get construction turns if end turn this num turn common variables l player buildings get i set status o o ok
calculate constructions turns for buildings
public void set position y int pos this position y pos
method that sets the position y of the vehicle
private void write file planets open the flow to write try write files build writer data zplanets catch exception e system err println e get message system exit 1 write information into the file write files file out println create file planets close the flow to write try write files close streams catch exception e system err println e get message system exit 1 end of write file planets
method that writes the data into the hdd
public void set position x final int pos this position x pos
method that sets the position x of the building
private void calculate buildings expirations for int i 0 i common variables l player buildings size i if common variables l player buildings get i get expire turn this num turn common variables body msg building common variables l player buildings get i expired common variables l players msgs add general functions send msg to player common constants msgfrom player governor common constants subject cof building expired common variables body msg common variables l player buildings get i set status b b broken down
calculate expirations turns for buildings
public void set position y final int pos this position y pos
method that sets the position y of the building
private string buffer create file planets todo string buffer commands new string buffer n planets n n parameters name abbreviation language flag file n for int i 0 i l planets size i commands append l planets get i to command n return commands end of create commands planets
method that creates the strings about planets to write into the hdd
public void set creation turn final int turn this creation turn turn
method thats sets the creation turn of the builfing
public void set status final string stat this status stat
method that sets the status
private void calculate takeoffs landings todo
calculate takeoffs and landings
private string buffer create commands countries string buffer commands new string buffer n adding countries to the system n n countries n n parameters name abbreviation language flag n for int i 0 i common variables l countries size i commands append add country common variables l countries get i to command n return commands end of create commands countries
method that creates the strings about countries to write into the hdd
private string buffer create commands players details string buffer commands new string buffer n adding personal details of the players in the system n n personal details n n parameters id player nickname password question remember pwd answer remember pwd real name language email address phone number town country avatar num games played num games won date last game played num turns played n return commands end of create commands players
method that creates the strings about players details to write into the hdd
private string buffer create commands technologies string buffer commands new string buffer n adding technologies to the system n n parameters code level required description tech req1 quantity tech req1 tech req2 quantity tech req2 tech req3 quantity tech req3 turns remained n for int i 0 i l players size i commands append add personal details l players get i to command details n return commands end of create commands players
method that creates the strings about technologies to write into the hdd
private void write file technologies open the flow to write try write files build writer data ztechnologies false catch exception e system err println e get message system exit 1 write information into the file write files file out println create file technologies close the flow to write try write files close streams catch exception e system err println e get message system exit 1 end of write file technologies
method that writes the data into the hdd
private void read commands try read files build reader common constants commands file catch exception e system err println e get message system exit 1 try write files build writer common constants results file false catch exception e system err println e get message system exit 1 server new server read files file in write files file out try server load file catch server exception e system err println e get message system exit 1 end of read commands
method that read commands to create the game
private string buffer create file technologies string buffer commands new string buffer n technologies n n parameters id technology level required description tech req1 quantity tech req1 tech req2 quantity tech req2 tech req3 quantity tech req3 turns remained n for int i 0 i common variables l technologies size i commands append common variables l technologies get i to command n return commands end of create commands technologies
method that creates the strings about technologies to write into the hdd
private void write file planets open the flow to write try write files build writer data zplanets false catch exception e system err println e get message system exit 1 write information into the file write files file out println create file planets close the flow to write try write files close streams catch exception e system err println e get message system exit 1 end of write file planets
method that writes the data into the hdd
private string buffer create file planets todo string buffer commands new string buffer n planets n n parameters name abbreviation language flag file n for int i 0 i common variables l planets size i commands append common variables l planets get i to command n return commands end of create commands planets
method that creates the strings about planets to write into the hdd
public int get num turns return this num turns
method that returns the number of the turns to execute
private vehicle search vehicle string id vehicle for int i 0 i common variables l vehicles size i if extractor common variables l vehicles get i get id compare to id vehicle 0 return vehicle common variables l vehicles get i return null
method that returns a vehicle from his id
public void run iaction action message dialog open information window get shell ai plug in hello eclipse world
the action has been activated
public void selection changed iaction action iselection selection sel selection changed selection
selection in the workbench has been changed
public void selection changed iselection selection if selection instanceof istructured selection this selection istructured selection selection
called when selection is changed
public void set my result compilation unit result this my result result
set compilation unit this visitor visits
public void set my source string string string this my source string
set the source file converted to string basing on which the compilation