MyGameGui - VadimKachevski/OOP_Ex3 GitHub Wiki

This class represents the visual part of this project.

Here all the painting of the Graph, Bots, Fruits & design happens.

alt text

This class is represented by these elements;

graph graph – represents a graphHashtable<Point3D,fruitInterface> fruits – represents a Hashtable of all the fruits.

Hashtable<Integer,robotInterface> bots - represents a Hashtable of all the Bots.

double minx=Integer.MAX_VALUE - represents the minimum x of the nodes location.

double maxx=Integer.MIN_VALUE - represents the maximum x of the nodes location.

double miny=Integer.MAX_VALUE - represents the minimum y of the nodes location.

double maxy=Integer.MIN_VALUE - represents the maximum y of the nodes location.

Thread t – t is the thread that starts the KML.

double x=0 – will represent the x location of the mouse click

double y=0 - will represent the y location of the mouse click

double timeGame=0 - time of the game.

game_service game – represents the game server.

boolean isBotChooser = true – represents if it’s the Bot’s turn to choose.

int botidtoMove - the Bot that its his turn to move.

KML_Logger k – k is the element which we will buld the KML with

This class has two constructors;

public MyGameGUI(graph g) – receives only a graph.

public MyGameGUI() – a default constructer

The other methods of this class

public void setXY(double xpos,double ypos) - Sets the X and Y position of the mouse on click

public void ThreadKML - A KML thread to save the game status in a KML file every 100 miliseconds

private void initGUI - Initiates the GUI and preparing it work with a given graph. Setting canvas size, enabling double buffering, building a graph, building the KML file base and setting the scale.

public void paint() - This method visually paints the graph, Bots & Fruits

public void Play_manual(String fromS) -This method receives a string and initiates an object from the type of manuelGame and activates it

public void gameInit(int gameNum) - This method initiates the game by clearing the game and then adding all of the game elements again (fruis bots & graph)

public void Play_Automaticly(String S) - This method receives a string initiates an object from the type of manuelGame and activates it

public void Init_Scores() – this method makes a table of all the data for a selected id.

The data which is shown is;

game cases

levels

best result for each case

amount of moves

moves allowed

score to reach

Rank

private static int whichStage(int index) - By a given a case number this method helps us translate the case number to its level number which represents the given case number and returns it.