mercredi 2 août 2017

Java proper parsing

I m finding the best way to parse hand written data into objects.

Lets say I have an interface called IEvent.

Lets say I have two class EventNewPlayer and EventUpdateTime which both implements the interface IEvent

The class EventNewPlayer requires 2 integers and one string. Lets say position X and Y and the name of the player

The class EventUpdateTime only requires one argument: the time.

I would like to make as create as much events as I want, from a hand written file

The file would look like this:

NEWPLAYER, 4, 2, joe
NEWPLAYER, 8, 9, bob
UPDATETIME, 1
NEWPLAYER, 8, 9, carl
UPDATETIME, 3

I would like to generate a list of events from this file. Also I would like in the future to add as much event as I want.

What is the best/proper/maintenable way to do this?

Sorry about any english mistakes, English is not my first langage.

Aucun commentaire:

Enregistrer un commentaire