FileDocCategorySizeDatePackage
PlayerParameters.javaAPI DocExample2923Tue Dec 12 18:58:42 GMT 2000bingo.player

PlayerParameters

public class PlayerParameters extends Parameters

Fields Summary
private boolean
shouldBeep
private String
name
private String
hostname
private int
numCards
private long
seed
private String
shouldBeepName
private String
nameName
private String
hostnameName
private String
numCardsName
Constructors Summary
PlayerParameters()


     
	super("bingoPlayer.props", "BINGO Player Properties");

	try {
            hostname = InetAddress.getLocalHost().getHostName();
	} catch (java.net.UnknownHostException e) {
	    //do nothing
	}

	getParameters();
    
Methods Summary
java.lang.StringgetHostname()

	return hostname;
    
java.lang.StringgetName()

	return name;
    
intgetNumCards()

	return numCards;
    
longgetSeed()

	return seed;
    
booleangetShouldBeep()

	return shouldBeep;
    
protected voidsetDefaults(java.util.Properties defaults)

	defaults.put(shouldBeepName, new Boolean(shouldBeep).toString());
	defaults.put(nameName, name);
	defaults.put(hostnameName, hostname);
	defaults.put(numCardsName, new Integer(numCards).toString());
    
voidsetHostname(java.lang.String hostname)

	this.hostname = hostname;
	saveParameters();
    
voidsetName(java.lang.String name)

	this.name = name;
	saveParameters();
    
voidsetNames(java.lang.String name, java.lang.String hostname)

	this.name = name;
	this.hostname = hostname;
	saveParameters();
    
voidsetNumCards(int numCards)

	this.numCards = numCards;
	saveParameters();
    
voidsetSeed(long seed)

	this.seed = seed;
    
voidsetShouldBeep(boolean shouldBeep)

	this.shouldBeep = shouldBeep;
	saveParameters();
    
public java.lang.StringtoString()

	return "["
	       + shouldBeep + ","
	       + name + ","
	       + hostname + ","
	       + numCards + "]";
    
protected voidupdatePropertiesFromSettings()

	properties.put(shouldBeepName,
		       new Boolean(shouldBeep).toString());
	properties.put(nameName,
		       name);
	properties.put(hostnameName,
		       hostname);
	properties.put(numCardsName,
		       new Integer(numCards).toString());
    
protected voidupdateSettingsFromProperties()

	try {
	    String tmp;
	    tmp = properties.getProperty(shouldBeepName);
	    shouldBeep = new Boolean(tmp).booleanValue();

	    name = properties.getProperty(nameName);

	    hostname = properties.getProperty(hostnameName);

	    tmp = properties.getProperty(numCardsName);
	    numCards = Integer.parseInt(tmp);
	} catch (NumberFormatException e) {
            // we don't care if the property was of the wrong format,
            // they've all got default values. So catch the exception
            // and keep going.
	}