Suggested Projects


Skill-Building Exercises

  1. Programming:   Modify the simple socket-based server application given in example 20.1 so that it is multi-threaded. You can get some ideas on how to proceed with this exercise by studying the ThreadedClientProcessor class code given in example 20.15. Test your work by attempting to connect with multiple SimpleClient applications.

  2. Programming:   Modify the robot rat client-server application presented in this chapter so that clients have some way of keeping track of their robot rat’s location on the floor. One possible solution might be to give the clients their own local floor. This modification will require changes to both the client and the server applications. The server will need to return rat position data to the client after each move. The client application must be able to properly utilize this data in some way.

  3. Programming:   Modify the robot rat client-server application presented in this chapter so that clients can see the positions on the floor of all the other robot rats, including its own.

  4. Programming:   Modify the robot rat client-server application presented in this chapter so that clients can destroy enemy robot rats.

  5. Programming:   Modify the robot rat client-server application presented in this chapter so that the server application configuration settings can be set via a dialog window from a client application. Make the ability to change the server setting password controlled.

  6. Programming:   Modify the robot rat client-server application presented in this chapter so that the height and width of the floor, and its location on the computer screen, will be automatically saved into the image from book netratserver.properties file whenever the floor is moved or resized. The following example code will give you a clue regarding how you might proceed with this enhancement.

    Example 20.21: PCTest.java

    image from book
     1     import java.awt.event.*; 2     import java.awt.*; 3     import javax.swing.*; 4 5     public class PCTest extends JFrame implements ComponentListener { 6 7       public PCTest(){ 8         this.setSize(200, 200); 9         this.setLocation(300, 300); 10        this.addComponentListener(this); 11        this.show(); 12      } 13 14      public void componentHidden(ComponentEvent e){ } 15      public void componentMoved(ComponentEvent e){ 16        Point point = this.getLocation(new Point()); 17        System.out.println("Location x: " + point.getX() + " " + "Location y: " + point.getY()); 18        } 19 20      public void componentResized(ComponentEvent e){ 21        System.out.println("Height: " + this.getHeight() + " " + "Width: " + this.getWidth()); 22       } 23 24      public void componentShown(ComponentEvent e){ } 25 26      public static void main(String[] args){ 27         new PCTest(); 28 29      } 30    } // end PCTest class definition
    image from book

  7. Programming:   Modify the robot rat client-server application presented in this chapter so that client applications have the ability to add or remove robot rats. Ensure that all of a client’s remaining robot rats are removed from the floor when a client application disconnects before removing all of its robot rats. Also, give the client applications the ability to select different robot rats for movement or removal.

  8. Programming:   Modify the robot rat client-server application presented in this chapter so that robot rat images displayed on the floor include some kind of client ID that allows robot rats to be correlated with their owing client application.




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net