Solutions to Self-Study Exercises


[Page 763 (continued)]

Solution 15.1

The fully connected mesh topology requires the most cables.

Solution 15.2

The fully connected mesh topology would have the most potential to use alternative routes if one of the host computers crashed.

Solution 15.3

The star topology would be rendered completely useless if its central hub crashed.

Solution 15.4

Prentice Hall's Web server is located at

http://www.prenhall.com

The protocol is http. The host computer is named www. Prentice Hall's domain name is prenhall, and it is part of the com (commercial) Internet domain.


[Page 764]
Solution 15.5

  • For buying a piece of software at a bookstore, the server would be the sales clerk. The protocol would be to select the software from off the shelf, bring it to the checkout counter, give the sales clerk money, and get a receipt.

  • For buying a piece of software over the phone, the server would be the telephone sales clerk. The protocol would be to select from a catalog, provide the sales clerk with your credit card information, and say goodbye.

  • For buying a piece of software over the Internet, the server would be the computer that handles the transaction. The protocol would be to select the item from a Web-based form, provide the form with personal and payment information, and click on the Buy button.

Solution 15.6

To play sounds along with slides in the SlideShowApplet, you would make the following modifications to the code:

private URL soundURL[] = new URL[NIMGS]; 


Declare an array of URLs to store the URLs of the audio files you want to play.

Assign URLs to the array at the same time you input the images:

for (int k=0; k < NIMGS; k++) {   url = new URL( "http://starbase.trincoll.edu/~jjjava/slide" + k + ".gif");   slide[k] = getImage( url );   soundURL[k]       = new URL("http://starbase.trincoll.edu/~jjjava/sound" + k + ".au"); } 


Each time an image is displayed in paint(), play the corresponding sound by using the URL from the array:

public void paint(Graphics g) {     if (currentImage != null) {         g.drawImage(currentImage,10,10,this);         play( soundURL[currentImage] );     } } 


Solution 15.7

The scramble service would be implemented by defining two new classes: The ScrambleServer class is a subclass of Server, and the ScrambleClient class is a subclass of Client. The ScrambleClient would implement the requestService() method, and the ScrambleServer would implement the provideService() method.

Solution 15.8

  • If you specify the wrong host name or port, you will get the following exception: java. net.ConnectException: Connection refused.

  • If you leave off the \n in the writeToSocket() call, nothing will go wrong because the writeToSocket() method will catch this error and add the end-of-line character to the string before sending it to the server. The server reads lines from the client, so every communication must end with \n or the protocol will break down.




Java, Java, Java(c) Object-Orienting Problem Solving
Java, Java, Java, Object-Oriented Problem Solving (3rd Edition)
ISBN: 0131474340
EAN: 2147483647
Year: 2005
Pages: 275

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