ERTAN ZENCIR
MEHMET YUCEER
Objective :
Writing a Distributed Application in Java with networking. The goal of the project is to write a Java applet that communicates via networking. It also includes the use of RMI in client/server system.
Description of the Program:
This is an n-person game application server with client applets for
each player. N people can play the game through applets.RMI is used for
the applets to communicate with the game server. The game server keeps
track of who is signed in to the session, keeps all information about
the clients and whenever a user acts in some way, broadcasts it to
the other clients.
After the applet is activated you have to login either to goalie or
player list which keeps the names of the current clients. You have to match
with a client on the other list( if you are a player, the other must be
a goalie, vice versa.).Otherwise it says " Illegal Selection" at the bottom
status bar.
To start the game ,click the button on the applet, named "start game".
If you are a player, click the bluebutton once to set the ball location,
and by using the scrollbars set the location of the target. Once
again click the blue button and the ball goes to the target. In the
same way you have to choose one point by mouse to catch the ball
if you are a goalie.
Ertan Zencir has prepared the Client side of the program, whileMehmet Yuceer has prepared the Server side of the project.
The main classes and methods used in the program are:
GameBase( ): This class runs at
the client side when the applet is activated at the start of the game.
It is not working with Netscape/IE Browsers because of technical
problems due to network security.
Each client should run an appletwiever to activate the game.
GameServer( ): This class runs at the server side of the program and keeps track of the clients interactions and broadcasts the messages to each client accordingly using the RMI and Muhabere( ) class' interfaces.
The applet contains a Canvas class and other awt components.
In the frame we used Scrollbar components, buttons for closing the
frame and shooting the ball and
replacing it again. To replace the ball user click the blue button
on the frame once and once again to kick the ball.
public void init(); intially
set the applet layout and the images used at the applet.
public void paint (Graphics g);
once the init is used paint method draws the images.
class ButtonHandler implements
ActionListener; once the button is cilcked on the applet, it opens the
frame.
class NetWindow extends Frame implements
ActionListener; implements the methods to draw the
frame, like the buttons to quit the frame and to kick the ball, scrollbars
for target setting, and the other
images.
public void setParent(Penalty a )
; this method sets the ball location and kale(net) images.
NetWindow(String title), this is
the first instance of its class to construct the object.
private void add(Component c, GridBagLayout
gbl, GridBagConstraints gbc, int x, int y, int w, int h); in
the frame GridBagLayout is used which is the most flexible one for
future concerns.
public void actionPerformed( ActionEvent e);
this method is used accordingly when the buttons are
used at the frame.
class ScrollbarHandlerX implements
AdjustmentListener ; sets the horizontal lcation of the target.
class ScrollbarHandlerY implements
AdjustmentListener ; sets the vertical location of the target.
class DrawCanvas extends Canvas;
draw the images and other things on the frame
public void setBallX( int x)
public void setBallY( int y);these
methods of Canvas set the position of the ball initially.
public void start( ), this is used
to start the ball settings.
public void ballgone, after the
kick it starts a new ball class.
public void shoot( ), make the
kicking action by specifying the speed and size reduction of the ball.
class Ball implements Runnable
, treats the ball as a Thread and make use of the thread properties of
the
ball to run it separately.
The flowing algorithm is as follows;
"appletwiever http://... GameBase.html" command is run by including the address of the source instead of the dottes.
GameBase is the main class on the client side which collaborate with
server through Muhabere (and MuhabereInterface) and player window through
Netwindow. User information is stored in the GameBase with playerstate
class object mystate. Netwindow also has instances of Drawcanvas (kale)
ball and golee which extended from myobject class. Ball and goalie are
run as threads and send coordinate information to GameBase, GameBase forward
coming information to its partner by its Muhabere instance called network.
The partner on the other hand recieves the coordinates through the server
(GameServer and Muhabere) and give its Netwindow , DrawCanvas,Ball and
goalie instances.