//This is my first post ever so, please tell me if I did anything wrong. :D
I recently started "learning" Java and I just started coding a little csgo skin manager thingy. I wanted to add an object for every skin implemented in the game, so I started with an object array. Problem is there are ~608 skins in the game and I don't want to type
if(i+1 == [ID]){weapons = new Skins("weaponName", "skinName", "randomQuality", "garbageCollection", i+1)}
600+ times, is there any faster way?
Edit: I got all the information in a .ods file, so the "problem" is actually about the "code structure" and not the initialization itself
//Here are the two classes if they are relevant to you:
package cs.skins;
public class Main{
private static final int NUMBER_OF_SKINS = 608;
private Skins[] weapons;
public Main(){
weapons = new Skins[NUMBER_OF_SKINS];
initSkins();
}
private void initSkins(){
for(int i = 0; i < weapons.length; i++){
if(i+1 == 1){
weapons[i] = new Skins();
}else if(i+1 == 2){
weapons[i] = new Skins();
}
}
}
}
and:
package cs.skins;
public class Skins {
private String weapon;
private String skin;
private String quality;
private String collection;
private int id;
private int numberOwned;
public Skins(String weapon, String skin, String quality, String collection, int id){
this.weapon = weapon;
this.skin = skin;
this.quality = quality;
this.collection = collection;
this.id = id;
this.numberOwned = 0;
}
public String getWeapon() {
return weapon;
}
public void setWeapon(String weapon) {
this.weapon = weapon;
}
public String getSkin() {
return skin;
}
public void setSkin(String skin) {
this.skin = skin;
}
public String getQuality() {
return quality;
}
public void setQuality(String quality) {
this.quality = quality;
}
public String getCollection() {
return collection;
}
public void setCollection(String collection) {
this.collection = collection;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getNumberOwned() {
return numberOwned;
}
public void setNumberOwned(int numberOwned) {
this.numberOwned = numberOwned;
}
}