K
K
KurwaTM2021-01-18 23:31:53
Java
KurwaTM, 2021-01-18 23:31:53

Java how to make each character + 1?

Hello. How can I make each character be + 1 for example:

float pp; //изменяется
//и мне нужно чтобы когда pp = 1; то yy +1 .  pp = 2; то yy +1
float yy;
//я не хачу делать так 180 раз
if(pp == 1){
yy = yy + 1;
}
// а хочу упрастить

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
etozhesano, 2021-01-18
@etozhesano

pp++

V
Vladimir, 2021-01-19
@Asapin

If I understand correctly, then you need to increase yy by 1 every time pp changes? Those. it is trite to count how many times the pp variable has changed.
In this case, you can do this: wrap both variables in a class, and work with them only through getters and setters. There is a direct setter only for pp; inside it, yy is updated according to the rules you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question