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

2012/4/30

Variable Weights Help

1
2
3
danpost danpost

2012/5/1

#
Yeah, the scenario you got the Bar class from uses 8 bars; 4 always show, and the other 4 show only when transitioning is ON. All these changes brought the number of bars from 8 to 2, and removed transitioning, which was specific to the scenario you got the Bar class from. There are other things you could do, like since both bars are related to weight, you might want them to have the same bar color (this would mean removing lines 17 and 27, and just changing line 22 in the Bar class, setting the safeColor variable to the color of your choice).
JMoller JMoller

2012/5/2

#
ok now it works thanks for all your help and time :D
danpost danpost

2012/5/2

#
Actually, line 26 still has values from the scenario the Bar class came from. The Bar class constructor has 4 parameters, of which you have already adjusted the first one. The second parameter could be "Kg" or "Lbs.", or you could just leave it "". The third parameter is the initial value of the bar (whatever you want it to start at with respect to the weight of the item). The fourth and final parameter is the maximum value that is allowed for the bar (the highest weight allowed for the item). Since you only have two bars you could remove the 'for' structure and create the bars individually with the proper values for each. Then use the 'setMinimumValue' method on the bars to set the minimum weight allowed.
JMoller JMoller

2012/5/7

#
hey dan, another quick question, how do you change the max value of the bars from 255 to 400?
danpost danpost

2012/5/7

#
for individual bars: barName.setMaximumValue(400); for ALL bars: change the assignment value in the maximumValue declaration statement in the bar class
JMoller JMoller

2012/5/8

#
so would i change this code ?
 public void setMaximumValue(int maxVal) { if (maxVal > minimumValue) { maximumValue = maxVal; newImage(); } }
    
    public void setMinimumValue(int minVal) { if (minVal < maximumValue) { minimumValue = minVal; newImage(); } }
danpost danpost

2012/5/8

#
No. You would change the code near the top 'int maximumValue = 255;' to 'int maximumValue = 400;'
JMoller JMoller

2012/5/8

#
hmm, when i change private int maximumValue to 400 it maxes out at 255
sp33dy sp33dy

2012/5/8

#
Ignore my last statement. Just returned from holiday and I'm completely wrong!
JMoller JMoller

2012/5/8

#
huh?
sp33dy sp33dy

2012/5/8

#
I posted something really dumb and edited the post to hide my embarrassing mistake.. Unfortunately, there is no 'delete' option.
JMoller JMoller

2012/5/9

#
oh
JMoller JMoller

2012/5/9

#
dan is it possible to make one bar have a different max value to the other one?
danpost danpost

2012/5/9

#
danpost wrote...
for individual bars: barName.setMaximumValue(400); for ALL bars: change the assignment value in the maximumValue declaration statement in the bar class
The first line says it all! just change 'barName' to the name of the bar you want to change to maximum value of.
JMoller JMoller

2012/5/9

#
it doesnt work when i do it, i use
 Projectile.setMaximumValue(400);
         Counterwieght.setMaximumValue(4000)
and it comes up with cannot find symbol- method setMaximumValue(int) im sorry dan, i guess i should of told you that im not that good at greenfoot or java at that
There are more replies on the next page.
1
2
3