I'm trying to create a class BallField that receives attributes from the parent class Ball, the ball class has the attributes
private int ar = 100; //100%
private boolean furada = false;
Ball class (no imports):
public class Bola {
private int ar = 100;
private boolean furada = false;
public Bola() {
}
public Bola(int ar, boolean furada) {
this.ar = ar;
this.furada = furada;
}
public int getAr() {
return ar;
}
public void setAr(int ar) {
this.ar = ar;
}
public boolean isFurada() {
return furada;
}
public void setFurada(boolean furada) {
this.furada = furada;
}
}
FootballBall class (no imports):
public class BolaDeFutebol extends Bola{
private String material = "Capotão";
private String esporte = "Futebol";
public BolaDeFutebol(String material, String esporte) {
super();
this.material = material;
this.esporte = esporte;
}
public BolaDeFutebol() {
}
public String getMaterial() {
return this.material;
}
public void setMaterial(String material) {
this.material = material;
}
public String getEsporte() {
return this.esporte;
}
public void setEsporte(String esporte) {
this.esporte = esporte;
}
public void Mostrar(){
System.out.println("Quantidade de ar: " + super.getAr() + "%");
System.out.println("Furada status: " + super.isFurada());
System.out.println("Material: " + getMaterial());
System.out.println("Esporte: " + getEsporte());
}
public void Mostrar(int ar){
System.out.println("Quantidade de ar: " + super.getAr() + "%");
}
public void Furar(){
setFurada(true);
int ar = getAr();
new Thread(){
@Override
public void run() {
for(int i = 0; i < ar; setAr(ar--)){
try {
Mostrar(ar);
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
super.run();
}
}.start();
}
}
It's all working, but in this method (stick) of the FootballBall class I can not subtract the value from the air attribute:
public void Furar(){
setFurada(true);
int ar = getAr();
new Thread(){
@Override
public void run() {
for(int i = 0; i < ar; setAr(ar--)){
try {
Mostrar(ar);
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
super.run();
}
}.start();
}