CurrencyProto.java

jmud-0.11/src/CurrencyProto.java · 1.3 KB

From the archive jmud-0_11.tgz

Download the archive   « Back to the archive contents

import java.io.BufferedReader;
import java.io.IOException;
import java.util.StringTokenizer;

import util.file.InvalidFileFormatException;
import util.log.Log;
import misc.Separators;


class CurrencyProto extends ItemProto {

    int kind;
    int value;

    CurrencyProto(int zoneBase, int itemId, BufferedReader itemFile)
	throws InvalidFileFormatException {

	super(zoneBase, itemId, itemFile);
	Log.debug("Moeda: " + getName());

	try {
	    StringTokenizer tok = new StringTokenizer(itemFile.readLine());
	    if (!tok.hasMoreTokens())
		throw new InvalidFileFormatException();
	    kind = Integer.parseInt(tok.nextToken());
	    if (!tok.hasMoreTokens())
		throw new InvalidFileFormatException();
	    value = Integer.parseInt(tok.nextToken());
	}
	catch(IOException e) {
	    throw new InvalidFileFormatException();
	}
	catch(NumberFormatException e) {
	    throw new InvalidFileFormatException();
	}
	
    }

    protected void finalize() {
	super.finalize();
    }

    int getProtoType() {
	return Item.T_CURRENCY;
    }

    Item create() {
	return new Currency(this);
    }

    ////////////
    // Sheetable

    public String getSheet() {
	return super.getSheet() + Separators.NL + "Tipo: " + kind + "  Valor: " + value;
    }

    // Sheetable
    ////////////

}

Site Stats

Snippets: 1791
Codebases: 571