I am developing game portal content management system using java and j2ee technology. However i am stuck in my design implementation.
Here is the scenario:
Each Game object has attributes like id, name, developer, price, platformType, platformName and so on...
However the release date may be different for each platform - PC, Mobile, Console and so on. Of course it is the same with the price.
The other problem is that for example if the game is for PC platform it has requirements like RAM, Video card and so on. So I decided to make another class for the platformType.
Do you think that the following design is good?
Here is the main Game object class:
public class Game
{
private long systemId;
private String name;
private String developer;
private Date registerDate;
private ArrayList<GamePlatform> gamePlatforms;
private GameScore gameScore;
private GameRank gameRank;
private ArrayList<String> genre;
}
Here is the GamePlatform class and its subclasses
public abstract class GamePlatform
{
private Date releaseDate;
private int price;
private String name;
private PlatformType platformType;
public GamePlatform(Date releaseDate, int price, String name, PlatformType platformType) {
this.releaseDate = releaseDate;
this.price = price;
this.name = name;
this.platformType = platformType;
}
public abstract PlatformType getType();
}
child class 1
public class ConsolePlatform extends GamePlatform
{
public ConsolePlatform(Date releaseDate, int price, String name, PlatformType platformType) {
super(releaseDate, price, name, platformType);
}
@Override
public PlatformType getType()
{
return PlatformType.CONSOLE;
}
}
child class 2
public class MobilePlatform extends GamePlatform
{
public MobilePlatform(Date releaseDate, int price, String name, PlatformType platformType)
{
super(releaseDate, price, name, platformType);
}
@Override
public PlatformType getType()
{
return PlatformType.MOBILE;
}
child class 3
public class PCPlatform extends GamePlatform
{
private PCRequirements pcRequirements;
public PCPlatform(Date releaseDate, int price, String name, PlatformType platformType, PCRequirements pcRequirements)
{
super(releaseDate, price, name,platformType);
this.pcRequirements = pcRequirements;
}
public PCRequirements getPcRequirements() {
return pcRequirements;
}
public void setPcRequirements(PCRequirements pcRequirements) {
this.pcRequirements = pcRequirements;
}
@Override
public PlatformType getType()
{
return PlatformType.PC;
}
}
And finally i have Enum class for the platform types. Here it is:
public enum PlatformType
{
MOBILE
{
@Override
public String toString(){ return "Mobile";}
},
CONSOLE
{
@Override
public String toString(){ return "Console";}
},
PC
{
@Override
public String toString(){ return "PC";}
};
}
gameScore
andgameRank
probably belong inGamePlatform
, as a specific port may be considered 'bad'. \$\endgroup\$