[Solved] How to Implement class Alkio? [closed]


Why do you expect it to print (1,2,10)?

  1. You re-set the values to 2,5, 12 (eka.setAlkio(2, 5, 12);). (although, as commented to the question by @flesk, you don’t actually set them…)
  2. you didn’t override the toString method as you should have:

    public String toString(){
        return "("+rivi+","+sarake+","+arvo+")";
    }
    
  3. In your constructor, you don’t set the class members to the given parameters, because you hide them in the method, the constructor should be:

    public Alkio(int rivi, int sarake, int arvo){
        this.rivi= rivi;
        this.sarake=sarake;
        this.arvo=arvo;
    }
    

7

solved How to Implement class Alkio? [closed]