class Weapon {
private String name;
private int min_damage;
private int max_damage;
private int weight;
public Weapon(String name, int weight) {
this.name = name;
this.weight = weight;
}
public int getMinDamage() { return min_damage; }
public int getMaxDamage() { return max_damage; }
public void setMinDamage(int x) { min_damage = x; }
public void setMaxDamage(int x) { max_damage = x; }
}
and I want at beginning of the program to create three weapons like longSword, shortSword, saber, each of it would have parameters min_damage, max_damage, name and weight, so how I need to create them? I am thinking about two ways, first:
Weapon longSword = new Weapon("Long Sword", 10);
longSword.setMinDamage(5);
longSword.setMaxDamage(10);
second:
class longSword extends Weapon{
// same actions like upper
}
but I realise, that both methods are wrong, maybe you have any advice for java programming newbie? Thank you in advance