Really, the answer is that it depends entirely on you, your preferences, your programming style, etc. There are probably a hundred different ways to do this, and none of them is “right”. That’s the beauty of programming. It’s also part of what makes it so frustrating!
But I will say that one thing you should look into is the idea of favoring composition over inheritance.
Basically, your approach with the 1000 classes uses inheritance, and it would go something like this, where you inherit from a base class to create different items:
abstract class ItemParent{
public String getName();
public int getAttack();
}
class ItemOne extends ItemParent{
public String getName(){
return "Item One";
}
public int getAttack(){
return 10;
}
}
class ItemTwo extends ItemParent{
public String getName(){
return "Item Two";
}
public int getAttack(){
return -1;
}
}
But all of that could be simplified by using composition instead. You would create an Item class that is composed of the different aspects of an Item:
class Item{
private String name;
private int attack;
public Item(String name, int attack){
this.name = name;
this.attack = attack;
}
public String getName(){
return name;
}
public int getAttack(){
return attack;
}
}
And then to create a specific item, you would just create an instance:
Item itemOne = new Item("Item One", 10);
Item itemTwo = new Item("Item Two", -1);
Like I said, there are a hundred different ways to do this, even if you do try to favor composition over inheritance. This is just something you should keep in mind before you create 1000 mostly identical classes.