Archive for: September, 2014

THE SOURCE CODE

 THE SOURCE CODE Now that you know how to play’ the game, it is time to examine the Source code, for the game Since several of the classes are quite long, we will sprinkle throughout the code rather than leaving the code till the end. The APPLET Tag The APPLET tag for this game is simple. Just…

Read More →

THE GAME

THE GAME Before users can playar multiplayer game, they must choose somebody to play against. Rather than forcing a phone call to arrange’ a game, this applet takes a.different approach. When it is first run, it prompts the user to enter his or her name  This name is passed to the server, which broadcasts the player’s name…

Read More →

Scrabblet A Multiplayer Word Game

Scrabblet  A  Multiplayer   Word Game Scrabblet is.a complete multiplayer, networked, client server game. It is the most complicated applet in this book, and it handles some of the thorniest issues in Java programming. Scrabblct consists of more than 1,400 lines of code in 11 classes. Two of these classes arc part of the server side of the…

Read More →

Deconstruct versus Finalization

Deconstruct versus Finalization When you move from C++ to Java, one of the more subtle, yet important issues you will face is the difference between a C++ constructor a Java finalize() method. Although similar in many respects, their actual operation is distinctively different. Let’s. begin by reviewing the purpose and effect of n c++ destruction and the…

Read More →

Converting C++ Multiple Inhertance Hierarchies

Converting C++ Multiple Inheritance Hierarchies In both cases, subclass C inherits classes A and U. However, in the hierarchy on the left, C Inherits both A and B at the same time. In the one on the right, Inherits A,  B. By not allowing the inheritance of multiple base classes by a single subclass, Java Safety simplifies the Inheritance…

Read More →

The Lavatron Applet: ASpeirts Arena Display

The Lavatron Applet: ASpeirts Arena Display Lavatron is a sports arena lightbulb display. Normally, an applet doesn’t have much of a history, but this one does. David Lavallee, the author of the ImagcMenu applet from Chapter 30, wanted to achieve this kind of effect for a long time. The history of Lavatron begins way back in 1974, when…

Read More →

Hot Java

Hot Java This applet is “noth~l small example of the kind.of amazing performance you can squeeze out of Java if you are careful and diligent. David Lavallee uses many tricks to avoid excessive memory allocation and unnecessary calls to AWl’ drawing functions. Creating the lightbulb mask image from a small array of integers rather , than a loaded GIF…

Read More →

IntHash()

IntHash()  As mentioned in the preceding section, Color objects are stored in a hash table rather than creating the same ones over and over. As a further optimization, we created our own version of Java’s Hashtable class, which uses normal ints as keys rather than requiring an Object handle Integer data needs much less room to…

Read More →

update( )

update( ) Lavatron overrides update f ) to do nothing, because we don’t want AWT’s implementation to cause flicker, paint( ) The paint() method is quite simple. The first step calls copyArea( ) to all of the columns to the left by one column’s width, Then a for loop is used to fill the rightmost column with…

Read More →

createBulbs( )

createBulbs( ) The crcatcBulbs( ) method is a helper to init( ). It returns an Image of a stack of bulb images that can be used Lomask out a column of colored squares to make them look like lit lightbulbs. It is a littletricky, but quite elegant. I First, it allocates the right number of ints in an…

Read More →

Back to Top