Hi there, I really need help understanding what these lines of code say. Would really appreciate if anyone could help me out. Thak you!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | */ public class Counter extends Actor { private static final Color textColor = new Color( 255 , 180 , 150 ); public int target = 0 ; private int stringLength; private String text; public Counter() { this ( "" ); } public Counter(String prefix) { text = prefix; stringLength = (text.length() + 2 ) * 10 ; setImage( new GreenfootImage(stringLength, 16 )); GreenfootImage image = getImage(); image.setColor(Color.BLACK); updateImage(); } public void act() { updateImage(); } public void add( int score) { target += score; } private void updateImage() { GreenfootImage image = getImage(); image.clear(); image.drawString(text + target, 1 , 12 ); } } |