Hi again,
Just thought I'd wrap this up, solved the "puzzle" so to say ^^
What i did was this:
Class:
public class LagerVara {
private String namn;
private double pris;
private int antal;
public LagerVara (){
//tom konstruktor
}
public LagerVara (String namn){
this.namn=namn;
}
public LagerVara (double pris){
this.pris=pris;
}
public LagerVara (int antal){
this.antal=antal;
}
public String getNamn (){
this.namn=namn;
return this.namn ;
}
public double getPris (){
this.pris=pris;
return this.pris ;
}
public int getAntal (){
this.antal=antal;
return this.antal ;
}
public void setNamn (String namn){
this.namn=namn;
}
public void setPris (double pris){
this.pris=pris;
}
public void setAntal (int antal){
this.antal=antal;
}
}
and the GUI code turned out like this:
LagerVara l=new LagerVara();
String LagerVaror [][]=new String [30][4];
double total=0;
double lvarde=0;
int index=0;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jTextArea1.setText(null);
l.setNamn(jTextField1.getText());
l.setPris(Double.parseDouble(jTextField2.getText()));
l.setAntal(Integer.parseInt(jTextField3.getText()));
LagerVaror[index][0] = l.getNamn();
LagerVaror[index][1] = String.valueOf(l.getPris());
LagerVaror[index][2] = String.valueOf(l.getAntal());
LagerVaror[index][3] = String.valueOf((l.getPris()*l.getAntal()));
index++;
total=l.getPris()*l.getAntal();
for (int i = 0; i < index; i++){
jTextArea1.append("Varunamn: " + LagerVaror[i][0] +" "
+ "Pris: " + LagerVaror[i][1] +" "
+ "Antal: " + LagerVaror[i][2] +" "
+ "Värde: " + LagerVaror[i][3] +"\n");
total=total+total;
}
jTextArea1.append("LagerVärde: " +total);
}
Now to have some fun the rest of the day before diving into the next problem tomorrow
Thanks for linking me to the code-snippets section, was most helpful