Tournament program

Ok im trying to make different types of tournaments..something like this

publicabstractclass Tournament{

private String tourny_name;

private Date date_started;

private List<Subscriber> list_subscribers =new LinkedList<Subscriber>();

public Tournament(String name1, Date date_started1){

this.tourny_name = name1;

this.date_started = date_started1;

}

}

Wat im trying to do is different types of tournaments..like leagues where every player has his points and if its a tournament of the type Pyramid it should show in wat level of the pyramid the player is.

I could make a class Subscriber like this:

publicclass Subscriber{

private Player player;

privateint points = 0;

privateint level = 1;//level 1 being at the top of the pyramid

public Subscriber(Player player,int points){

this.player = player;

this.points = points;

}

public Subscriber(Player player,int level){

this.player = player;

this.level = level;

}

}

If i do a class Subscriber to tht specific tourny tht would mean tht i would use either the level or the points not both of the private int variables (i know the compiler doesnt let me do this 2 constructors because they are the same for him) and this is a bad way to solve the problem i think.

Any of u know how to solve this kind of problem? i would rather not to mess with the Player class because its dependable of PlayerManager.

Thanks in advance :)

[2470 byte] By [HighMagea] at [2007-11-27 10:27:29]
# 1

You know it doesn't cost you any money to post on these fora, so please type words out in full!

floundera at 2007-7-28 17:46:03 > top of Java-index,Java Essentials,Java Programming...
# 2

oh sorry it's just that im used to talk on chatrooms, i'll try remembering about that :s

Writting like this is ok?

HighMagea at 2007-7-28 17:46:03 > top of Java-index,Java Essentials,Java Programming...
# 3

how about an AbstractSubscriber class that has just the common features (in your example, that would only be Player), then subclass this to PyramidSubscriber that has a level field and TournamentSubscriber that has a points field.

petes1234a at 2007-7-28 17:46:03 > top of Java-index,Java Essentials,Java Programming...
# 4

hmm, don't know if that will work, i'll try and see what happens, thanks :)

HighMagea at 2007-7-28 17:46:03 > top of Java-index,Java Essentials,Java Programming...
# 5

oh and another thing..I noticed that if i make a List<Subscriber> i only have acess to the methods of the abstract class Subscriber, so if i want to acess the methods in the PyramidSubscriber for example ill have to make like this:

if (s instanceof PyramidSubscriber)

PyramidSubscriber = (PyramidSubscriber)s;

or..i can make a List specifically for tht subclass (List<PyramidSubscriber>)?

I think what the tournaments have in common is the subscribers, wouldn't it be bad if i made a List<PyramidSubscriber> in the class PyramidSubscriber?

HighMagea at 2007-7-28 17:46:03 > top of Java-index,Java Essentials,Java Programming...