This site requires JavaScript, please enable it in your browser!
Greenfoot back
zaenal97
zaenal97 wrote ...

2016/12/5

how to create an object with a different score?

zaenal97 zaenal97

2016/12/5

#
ex: object1 = 10; object2 = 20;
Super_Hippo Super_Hippo

2016/12/5

#
private int score;

public ClassName(int points)
{
    score = points;
}


//and when creating it
addObject(new ClassName(10), ..., ...); //or 20
Or
private int score;

public void setScore(int points)
{
    score = points;
}


//and when creating it
ClassName obj = new ClassName();
obj.setScore(10); //or 20
addObject(obj, ..., ...);
You need to login to post a reply.