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

2020/6/12

how to use increment operator

1
2
Roshan123 Roshan123

2020/6/12

#
plz tell me how will i write this to increase in decimal points
health+=1 // i want it to increase in decimal i.e. 1.1, 1.2, 1.3,......
Kostya20052011 Kostya20052011

2020/6/12

#
Make a health variable of the double type, and then write this line: health=health+0.1; Also, if you need to Express it in int, then you need to write this: (int)(health)
Roshan123 Roshan123

2020/6/12

#
i want my health to be 100(not in decimal) and if it increases then it should increase in decimal
Roshan123 Roshan123

2020/6/12

#
is it ok int health=100; double health+=0.1;
Kostya20052011 Kostya20052011

2020/6/12

#
dooble health=100; health+=0.1;
Roshan123 Roshan123

2020/6/12

#
ok ;thanks
Roshan123 Roshan123

2020/6/12

#
but i have some issues
Roshan123 Roshan123

2020/6/12

#
you know that its a very silly question and everybody would be knowing that
Roshan123 Roshan123

2020/6/12

#
to show the issues, i have to show a lots of code and i dont want it to be seen by others is their any way from which i can show my code to you privately
Roshan123 Roshan123

2020/6/12

#
the question which i m asking is linked with 5 classes in 1st world and 6 classes in 2nd world.
Roshan123 Roshan123

2020/6/12

#
if i will share also, i dont think so that anybody will read a lot of codes
Kostya20052011 Kostya20052011

2020/6/12

#
Well, if you are in social networks, then we can become friends there and communicate so that no one else can see. You have accounts in some social networks: Telegram, Vkontakte, facebook?
Roshan123 Roshan123

2020/6/12

#
i dont use any social media
Roshan123 Roshan123

2020/6/12

#
i think i m running out of luck
danpost danpost

2020/6/12

#
I would still use an int, but starting at 1000:
public int health = 1000;

// subtract and add using
health++;
//
health--;

// display using
showText("Health: "+(health/10), 60, 30);
This will show health (between 0 and 100) in normal units, but track health in units of 1/10th of a normal unit.
There are more replies on the next page.
1
2