-1

The method is only ment to change the attribute value and does not have to call any other methods such as Draw().

class Rechteck {

    int xPosition;
    int yPosition;
    int breite;
    int hoehe;
    String farbe;

    void verschiebeWaagerecht(int xPosition){ 
       //The method that is ment to change the position of the rectangle.            
    }
}
madhepurian
  • 271
  • 1
  • 13
  • So basically what is your question / doubt ? – SSP Sep 26 '19 at 19:32
  • Did you write this code yourself? Just add the parameter to your xPosition or set the parameter as the new xPosition, depending what exaxtly it is supposed to do... – GitPhilter Sep 26 '19 at 19:35
  • The method "verschiebeWaagerecht" doesnt change the position of the recantangle horizontally. I want to know what I have to write instead. –  Sep 26 '19 at 19:35
  • 2
    Of course it doesnt change anything because it doesnt even try to do anything^^ – GitPhilter Sep 26 '19 at 19:35
  • btw: you should also think about writing a constructor for your class. Maybe you just left it out for readability purposes, but I am just saying... – GitPhilter Sep 26 '19 at 19:40
  • I left the constructor out. Im just getting started with Java so Im really thankful for all the great tips :) –  Sep 26 '19 at 19:50

1 Answers1

1

If you just want to move horizontally, you need to add value passed as an argument, like that

void verschiebeWaagerecht(int xPosition){ 
 this.xPosition += xPosition;
}
jaroslawj
  • 462
  • 2
  • 12