Hola he tratado de hacer un contador con Java , al momento de ejecutar el código el contador no funciona pero ya he tratado de colocar ciclo for , while , pero nada arranca este es mi código, pensaria que el error esta en los métodos que cree para incrementar y decrementar , o tal vez en la clase main a l ahora de obtener el valor del contador
package counter;
public class Counter {
private int counter = 0;
static int decision;
public Counter() {
}
public Counter(int counter) {
this.counter = counter;
}
public int getCounter() {
return counter;
}
public void setCounter(int counter) {
this.counter = counter;
}
public void increase() {
if(counter >= 0 ) {
counter++;
}
}
public void decrease() {
if (counter <= 0) {
counter = counter--;
}
}
}
package counter;
import java.util.Scanner;
public class CounterMain extends Counter {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Counter countermain = new Counter();
System.out.println("give me a number");
int number = in.nextInt();
countermain.setCounter(number);
System.out.println(countermain.getCounter());
countermain.increase();
System.out.println(countermain.getCounter());
countermain.decrease();
System.out.println(countermain.getCounter());
}
}